...
This commit is contained in:
@@ -11,11 +11,13 @@ namespace Back.Services
|
||||
{
|
||||
private readonly IAsyncRepository<CODItem> _CODRepo;
|
||||
private readonly IAsyncRepository<CODUnit> _UnitRepo;
|
||||
public ServCOD(IAsyncRepository<CODItem> CODRepo, IAsyncRepository<CODUnit> unitRepo)
|
||||
private readonly CheckPermission _checkPermission;
|
||||
public ServCOD(IAsyncRepository<CODItem> CODRepo, IAsyncRepository<CODUnit> unitRepo
|
||||
, CheckPermission checkPermission)
|
||||
{
|
||||
_CODRepo = CODRepo;
|
||||
_UnitRepo = unitRepo;
|
||||
|
||||
_checkPermission = checkPermission;
|
||||
}
|
||||
public async Task<PagingDto<RCOD>?> GetCODs(int CompanyID, ItemSerchGetCOD itemSerch)
|
||||
{
|
||||
@@ -47,6 +49,7 @@ namespace Back.Services
|
||||
TaxID = s.ItemTaxID,
|
||||
Title = s.Title,
|
||||
Unit = s.CODUnit.Title,
|
||||
UnitID=s.UnitID,
|
||||
TaxRate = s.TaxRate
|
||||
})
|
||||
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
|
||||
@@ -55,5 +58,96 @@ namespace Back.Services
|
||||
{
|
||||
return await _UnitRepo.GetAll().Select(s => new IdName<int> { ID = s.ID, Title = s.Title }).ToListAsync();
|
||||
}
|
||||
public async Task<CODItem?> GetCodByCodID(int CodID, int CompanyID)
|
||||
{
|
||||
return await _CODRepo
|
||||
.Get(w => w.ID == CodID && w.CompanyID == CompanyID && !w.IsDeleted).FirstOrDefaultAsync();
|
||||
}
|
||||
public async Task<bool> ExistCodByCustomerID(int CodID, int CompanyID)
|
||||
{
|
||||
return await _CODRepo
|
||||
.Get(w => w.ID == CodID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
||||
}
|
||||
public async Task<bool> ExistUnit(int UnitID)
|
||||
{
|
||||
return await _UnitRepo
|
||||
.Get(w => w.ID == UnitID ).AnyAsync();
|
||||
}
|
||||
public async Task<bool> AddOrUpdateCod(CODItem item)
|
||||
{
|
||||
try
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddORUpdateCustomer",
|
||||
// Value = "*" + JsonConvert.SerializeObject(item),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
|
||||
if (item.ID == null || item.ID <= 0)
|
||||
{
|
||||
var ret = await _CODRepo.AddBoolResultAsync(item);
|
||||
await _checkPermission.ExtensionofAccess(item.CompanyID, 5, "-1");
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _CODRepo.UpdateAsync(item);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/AddORUpdateCustomer",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<bool> DeleteCod(CODItem item)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
item.IsDeleted = true;
|
||||
return await _CODRepo.UpdateAsync(item);
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/DeleteCustomer",
|
||||
// Value = JsonConvert.SerializeObject(item.ID),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//SysLog log = new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/DeleteCustomer",
|
||||
// Value = ex.Message,
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "catch"
|
||||
//};
|
||||
//_contextMongodb.InsertItem(log);
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user