public ActionResult Insert(MActionItem viewModel, FormCollection formCollection) { MActionItem actionItem = new MActionItem(); actionItem.SetAssignedIdTo(Guid.NewGuid().ToString()); TransferFormValuesTo(actionItem, viewModel); actionItem.ItemId = _mItemRepository.Get(formCollection["ItemId"]); actionItem.ActionId = _mActionRepository.Get(formCollection["ActionId"]); actionItem.CreatedDate = DateTime.Now; actionItem.CreatedBy = User.Identity.Name; actionItem.DataStatus = EnumDataStatus.New.ToString(); _mActionItemRepository.Save(actionItem); try { _mActionItemRepository.DbContext.CommitChanges(); } catch (Exception e) { _mActionItemRepository.DbContext.RollbackTransaction(); //throw e.GetBaseException(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }
private void TransferFormValuesTo(MActionComm packetComm, MActionComm viewModel, FormCollection formCollection, string EmployeeId) { packetComm.ActionId = _mActionRepository.Get(formCollection["ActionId"]); packetComm.EmployeeId = _mEmployeeRepository.Get(EmployeeId); packetComm.ActionCommVal = viewModel.ActionCommVal; packetComm.ActionCommType = viewModel.ActionCommType; packetComm.ActionCommStatus = viewModel.ActionCommStatus; packetComm.ActionCommDesc = viewModel.ActionCommDesc; }
public ActionResult Delete(MAction viewModel, FormCollection formCollection) { MAction mActionToDelete = _mActionRepository.Get(viewModel.Id); if (mActionToDelete != null) { _mActionRepository.Delete(mActionToDelete); } try { _mActionRepository.DbContext.CommitChanges(); } catch (Exception e) { _mActionRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("success")); }