public MCustomer Update(Domain.MCustomer cust) { _customerRepository.DbContext.BeginTransaction(); _customerRepository.Update(cust); _customerRepository.DbContext.CommitTransaction(); return(cust); }
public ActionResult Update(MCustomer viewModel, FormCollection formCollection) { MCustomer customer = _mCustomerRepository.Get(viewModel.Id); TransferFormValuesTo(customer, viewModel); customer.ModifiedDate = DateTime.Now; customer.ModifiedBy = User.Identity.Name; customer.DataStatus = EnumDataStatus.Updated.ToString(); RefAddress address = customer.AddressId; TransferFormValuesTo(address, formCollection); customer.ModifiedDate = DateTime.Now; customer.ModifiedBy = User.Identity.Name; customer.DataStatus = EnumDataStatus.Updated.ToString(); RefPerson person = customer.PersonId; TransferFormValuesTo(person, formCollection); customer.ModifiedDate = DateTime.Now; customer.ModifiedBy = User.Identity.Name; customer.DataStatus = EnumDataStatus.Updated.ToString(); _mCustomerRepository.Update(customer); try { _mCustomerRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCustomerRepository.DbContext.RollbackTransaction(); //throw e.GetBaseException(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
public ActionResult Update(MCustomer viewModel, FormCollection formCollection) { UpdateNumericData(viewModel, formCollection); MCustomer mCustomerToUpdate = _mCustomerRepository.Get(viewModel.Id); TransferFormValuesTo(mCustomerToUpdate, viewModel); mCustomerToUpdate.ModifiedDate = DateTime.Now; mCustomerToUpdate.ModifiedBy = User.Identity.Name; mCustomerToUpdate.DataStatus = EnumDataStatus.Updated.ToString(); RefAddress address = mCustomerToUpdate.AddressId; TransferFormValuesTo(address, formCollection); address.ModifiedDate = DateTime.Now; address.ModifiedBy = User.Identity.Name; address.DataStatus = EnumDataStatus.Updated.ToString(); RefPerson person = mCustomerToUpdate.PersonId; TransferFormValuesTo(person, formCollection); person.ModifiedDate = DateTime.Now; person.ModifiedBy = User.Identity.Name; person.DataStatus = EnumDataStatus.Updated.ToString(); _mCustomerRepository.Update(mCustomerToUpdate); try { _mCustomerRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCustomerRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }