public IActionResult Remove(string id) { var result = ""; try { var poco = _customerLogic.GetSingleById(Convert.ToInt32(id)); if (poco != null) { _chartOfAccountLogic = new Lms_ChartOfAccountLogic(_cache, new EntityFrameworkGenericRepository <Lms_ChartOfAccountPoco>(_dbContext)); var accPoco = _chartOfAccountLogic.GetSingleById(poco.AccountId); _chartOfAccountLogic.Remove(accPoco); _customerAddressMappingLogic = new Lms_CustomerAddressMappingLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerAddressMappingPoco>(_dbContext)); var mappingAddresses = _customerAddressMappingLogic.GetList().Where(c => c.CustomerId == poco.Id).ToList(); if (mappingAddresses.Count > 0) { foreach (var item in mappingAddresses) { _customerAddressMappingLogic.Remove(item); } } _customerLogic.Remove(poco); } result = "Success"; } catch (Exception ex) { } return(Json(result)); }
private bool DeleteCustomerById(int customerId) { bool isDeleted = false; try { var poco = _customerLogic.GetSingleById(Convert.ToInt32(customerId)); if (poco != null) { _chartOfAccountLogic = new Lms_ChartOfAccountLogic(_cache, new EntityFrameworkGenericRepository <Lms_ChartOfAccountPoco>(_dbContext)); var accPoco = _chartOfAccountLogic.GetSingleById(poco.AccountId); _chartOfAccountLogic.Remove(accPoco); _customerAddressMappingLogic = new Lms_CustomerAddressMappingLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerAddressMappingPoco>(_dbContext)); var mappingAddresses = _customerAddressMappingLogic.GetList().Where(c => c.CustomerId == poco.Id).ToList(); if (mappingAddresses.Count > 0) { foreach (var item in mappingAddresses) { _customerAddressMappingLogic.Remove(item); } } _customerLogic.Remove(poco); isDeleted = true; } } catch (Exception ex) { // } return(isDeleted); }
public IActionResult Remove(string id) { var result = ""; try { var poco = _customerLogic.GetSingleById(Convert.ToInt32(id)); if (poco != null) { _chartOfAccountLogic = new Lms_ChartOfAccountLogic(_cache, new EntityFrameworkGenericRepository <Lms_ChartOfAccountPoco>(_dbContext)); var accPoco = _chartOfAccountLogic.GetSingleById(poco.AccountId); _chartOfAccountLogic.Remove(accPoco); } _customerLogic.Remove(poco); result = "Success"; } catch (Exception ex) { } return(Json(result)); }