This commit is contained in:
mmrbnjd
2024-05-08 17:25:02 +03:30
parent d74f3dadf3
commit 716f02baa1
14 changed files with 376 additions and 179 deletions

View File

@@ -58,24 +58,24 @@ namespace Back.Services
PassportNumber = s.PassportNumber,
CustomerType= s.CustomerType
// CompanyID=s.CompanyID
})
}).OrderByDescending(o=>o.ID)
.Paging(itemSerch.PageIndex, itemSerch.PageSize);
}
//public async Task<Customer> GetCustomerByCustomerID(int CustomerID, int CompanyID)
//{
// return await _repositores.GET<Customer>()
// .Where(w => w.ID == CustomerID && w.CompanyID==CompanyID && !w.IsDeleted).FirstOrDefaultAsync();
//}
public async Task<Customer?> GetCustomerByCustomerID(int CustomerID, int CompanyID)
{
return await _repoCus
.Get(w => w.ID == CustomerID && w.CompanyID == CompanyID && !w.IsDeleted).FirstOrDefaultAsync();
}
//public async Task<Customer> GetCustomerByCustomerID(int CustomerID)
//{
// return await _repositores.GET<Customer>()
// .Where(w => w.ID == CustomerID && !w.IsDeleted).FirstOrDefaultAsync();
//}
//public async Task<bool> ExistCustomerByCustomerID(int CustomerID, int CompanyID)
//{
// return await _repositores.GET<Customer>()
// .AnyAsync(w => w.ID == CustomerID && w.CompanyID == CompanyID && !w.IsDeleted);
//}
public async Task<bool> ExistCustomerByCustomerID(int CustomerID, int CompanyID)
{
return await _repoCus
.Get(w => w.ID == CustomerID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
}
//public async Task<CUCustomer> GetCustomerByCustomerIDByDTO(int CustomerID)
//{
// return await _repositores.GET<Customer>()
@@ -98,7 +98,7 @@ namespace Back.Services
// })
// .FirstOrDefaultAsync();
//}
public async Task<bool> AddCustomer(Customer item)
public async Task<bool> AddOrUpdateCustomer(Customer item)
{
try
{
@@ -113,7 +113,7 @@ namespace Back.Services
//};
//_contextMongodb.InsertItem(log);
if (item.ID == null || item.ID == 0)
if (item.ID == null || item.ID <= 0)
{
var ret = await _repoCus.AddBoolResultAsync(item);
await _checkPermission.ExtensionofAccess(item.CompanyID, 5, "-1");
@@ -140,41 +140,40 @@ namespace Back.Services
}
}
//public async Task<bool> DeleteCustomer(Customer item)
//{
public async Task<bool> DeleteCustomer(Customer item)
{
// try
// {
// item.IsDeleted = true;
// _repositores.UPDATE(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);
// return true;
// }
// 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;
try
{
item.IsDeleted = true;
return await _repoCus.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;
// }
//}
}
}
}