public void Update(SaleOrderSettings s) { s.ObjectState = ObjectState.Modified; _unitOfWork.Repository <SaleOrderSettings>().Update(s); }
public SaleOrderSettings Create(SaleOrderSettings s) { s.ObjectState = ObjectState.Added; _unitOfWork.Repository <SaleOrderSettings>().Insert(s); return(s); }
public void Delete(SaleOrderSettings s) { _unitOfWork.Repository <SaleOrderSettings>().Delete(s); }
public ActionResult PostCancel(SaleOrderSettingsViewModel vm) { SaleOrderSettings pt = AutoMapper.Mapper.Map <SaleOrderSettingsViewModel, SaleOrderSettings>(vm); if (pt.CalculationId <= 0) { ModelState.AddModelError("CalculationId", "The Calculation field is required"); } if (ModelState.IsValid) { if (vm.SaleOrderSettingsId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _SaleOrderSettingsService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(vm); return(View("CreateForCancel", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pt.DocTypeId, DocId = pt.SaleOrderSettingsId, ActivityType = (int)ActivityTypeContants.SettingsAdded, })); return(RedirectToAction("Index", "SaleOrderCancelHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleOrderSettings temp = _SaleOrderSettingsService.Find(pt.SaleOrderSettingsId); SaleOrderSettings ExRec = Mapper.Map <SaleOrderSettings>(temp); temp.filterLedgerAccountGroups = pt.filterLedgerAccountGroups; temp.filterLedgerAccounts = pt.filterLedgerAccounts; temp.filterProductGroups = pt.filterProductGroups; temp.filterProducts = pt.filterProducts; temp.filterProductTypes = pt.filterProductTypes; temp.filterPersonRoles = pt.filterPersonRoles; temp.CalculationId = pt.CalculationId; temp.SqlProcDocumentPrint_AfterApprove = pt.SqlProcDocumentPrint_AfterApprove; temp.SqlProcDocumentPrint_AfterSubmit = pt.SqlProcDocumentPrint_AfterSubmit; temp.isVisibleDimension1 = pt.isVisibleDimension1; temp.isVisibleDimension2 = pt.isVisibleDimension2; temp.isVisibleDimension3 = pt.isVisibleDimension3; temp.isVisibleDimension4 = pt.isVisibleDimension4; temp.SqlProcDocumentPrint = pt.SqlProcDocumentPrint; temp.UnitConversionForId = pt.UnitConversionForId; temp.ImportMenuId = pt.ImportMenuId; temp.isVisibleAdvance = pt.isVisibleAdvance; temp.isVisibleCurrency = pt.isVisibleCurrency; temp.isVisibleDeliveryTerms = pt.isVisibleDeliveryTerms; temp.isVisibleDealUnit = pt.isVisibleDealUnit; temp.isVisibleShipMethod = pt.isVisibleShipMethod; temp.isVisibleSpecification = pt.isVisibleSpecification; temp.isVisibleProductCode = pt.isVisibleProductCode; temp.isVisiblePriority = pt.isVisiblePriority; temp.isVisibleUnitConversionFor = pt.isVisibleUnitConversionFor; temp.isVisibleBillToParty = pt.isVisibleBillToParty; temp.isVisibleGodown = pt.isVisibleGodown; temp.isVisibleFinancier = pt.isVisibleFinancier; temp.isVisibleSalesExecutive = pt.isVisibleSalesExecutive; temp.isMandatoryRate = pt.isMandatoryRate; temp.isPostedInStock = pt.isPostedInStock; temp.CurrencyId = pt.CurrencyId; temp.DeliveryTermsId = pt.DeliveryTermsId; temp.ShipMethodId = pt.ShipMethodId; temp.Priority = pt.Priority; temp.ProcessId = pt.ProcessId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _SaleOrderSettingsService.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(vm); return(View("CreateForCancel", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.SaleOrderSettingsId, ActivityType = (int)ActivityTypeContants.SettingsModified, xEModifications = Modifications, })); return(RedirectToAction("Index", "SaleOrderCancelHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } } PrepareViewBag(vm); return(View("CreateForCancel", vm)); }