public ActionResult Post(MaterialRequestSettingsViewModel vm) { MaterialRequestSettings pt = AutoMapper.Mapper.Map <MaterialRequestSettingsViewModel, MaterialRequestSettings>(vm); if (ModelState.IsValid) { if (vm.MaterialRequestSettingsId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _MaterialRequestSettingsService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(); return(View("Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pt.DocTypeId, DocId = pt.MaterialRequestSettingsId, ActivityType = (int)ActivityTypeContants.SettingsAdded, })); return(RedirectToAction("Index", "MaterialRequestHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); MaterialRequestSettings temp = _MaterialRequestSettingsService.Find(pt.MaterialRequestSettingsId); MaterialRequestSettings ExRec = Mapper.Map <MaterialRequestSettings>(temp); temp.filterContraDocTypes = pt.filterContraDocTypes; temp.filterProductGroups = pt.filterProductGroups; temp.filterProducts = pt.filterProducts; temp.filterProductTypes = pt.filterProductTypes; temp.filterPersonRoles = pt.filterPersonRoles; temp.isMandatoryCostCenter = pt.isMandatoryCostCenter; temp.isMandatoryProcessLine = pt.isMandatoryProcessLine; temp.isVisibleCostCenter = pt.isVisibleCostCenter; temp.isVisibleDimension1 = pt.isVisibleDimension1; temp.isVisibleDimension2 = pt.isVisibleDimension2; temp.isVisibleDimension3 = pt.isVisibleDimension3; temp.isVisibleDimension4 = pt.isVisibleDimension4; temp.isVisibleLotNo = pt.isVisibleLotNo; temp.SqlProcDocumentPrint = pt.SqlProcDocumentPrint; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _MaterialRequestSettingsService.Update(temp); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(); return(View("Create", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.MaterialRequestSettingsId, ActivityType = (int)ActivityTypeContants.SettingsModified, xEModifications = Modifications, })); return(RedirectToAction("Index", "MaterialRequestHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } } PrepareViewBag(); return(View("Create", vm)); }
public void Update(MaterialRequestSettings pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <MaterialRequestSettings>().Update(pt); }
public MaterialRequestSettings Create(MaterialRequestSettings pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <MaterialRequestSettings>().Insert(pt); return(pt); }
public void Delete(MaterialRequestSettings pt) { _unitOfWork.Repository <MaterialRequestSettings>().Delete(pt); }
public MaterialRequestSettings Add(MaterialRequestSettings pt) { _unitOfWork.Repository <MaterialRequestSettings>().Insert(pt); return(pt); }