public ActionResult Delete(MSupplier viewModel, FormCollection formCollection) { MSupplier mSupplierToDelete = _mSupplierRepository.Get(viewModel.Id); if (mSupplierToDelete != null) { _mSupplierRepository.Delete(mSupplierToDelete); _refAddressRepository.Delete(mSupplierToDelete.AddressId); } try { _mSupplierRepository.DbContext.CommitChanges(); } catch (Exception e) { _mSupplierRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public ActionResult Delete(MCustomer viewModel, FormCollection formCollection) { MCustomer customer = _mCustomerRepository.Get(viewModel.Id); if (customer != null) { _mCustomerRepository.Delete(customer); _refAddressRepository.Delete(customer.AddressId); } try { _mCustomerRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCustomerRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }