public ActionResult Post(SaleDispatchSettingsViewModel vm) { SaleDispatchSetting pt = AutoMapper.Mapper.Map <SaleDispatchSettingsViewModel, SaleDispatchSetting>(vm); if (ModelState.IsValid) { if (vm.SaleDispatchSettingId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _SaleDispatchSettingService.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.SaleDispatchSettingId, ActivityType = (int)ActivityTypeContants.SettingsAdded, })); return(RedirectToAction("Index", "SaleDispatchHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleDispatchSetting temp = _SaleDispatchSettingService.Find(pt.SaleDispatchSettingId); SaleDispatchSetting ExRec = Mapper.Map <SaleDispatchSetting>(temp); temp.isVisibleProductUid = pt.isVisibleProductUid; temp.isVisibleProductCode = pt.isVisibleProductCode; temp.isVisibleLotNo = pt.isVisibleLotNo; temp.isVisibleBaleNo = pt.isVisibleBaleNo; temp.isVisibleDimension1 = pt.isVisibleDimension1; temp.isVisibleDimension2 = pt.isVisibleDimension2; temp.isVisibleDimension3 = pt.isVisibleDimension3; temp.isVisibleDimension4 = pt.isVisibleDimension4; temp.isVisibleSpecification = pt.isVisibleSpecification; temp.isVisibleDeliveryTerms = pt.isVisibleDeliveryTerms; temp.isVisibleDealUnit = pt.isVisibleDealUnit; temp.isVisibleShipMethod = pt.isVisibleShipMethod; temp.isVisibleForSaleOrder = pt.isVisibleForSaleOrder; temp.isVisibleWeight = pt.isVisibleWeight; temp.isVisibleStockIn = pt.isVisibleStockIn; temp.isVisibleFreeQty = pt.isVisibleFreeQty; temp.IsMandatoryStockIn = pt.IsMandatoryStockIn; temp.filterLedgerAccountGroups = pt.filterLedgerAccountGroups; temp.filterLedgerAccounts = pt.filterLedgerAccounts; temp.filterProductGroups = pt.filterProductGroups; temp.filterProducts = pt.filterProducts; temp.filterProductTypes = pt.filterProductTypes; temp.filterContraDocTypes = pt.filterContraDocTypes; temp.filterContraDivisions = pt.filterContraDivisions; temp.filterContraSites = pt.filterContraSites; temp.filterPersonRoles = pt.filterPersonRoles; temp.UnitConversionForId = pt.UnitConversionForId; temp.SqlProcDocumentPrint = pt.SqlProcDocumentPrint; temp.SqlProcDocumentPrint_AfterApprove = pt.SqlProcDocumentPrint_AfterApprove; temp.SqlProcDocumentPrint_AfterSubmit = pt.SqlProcDocumentPrint_AfterSubmit; temp.SqlProcGatePass = pt.SqlProcGatePass; temp.ShipMethodId = pt.ShipMethodId; temp.GodownId = pt.GodownId; temp.ProcessId = pt.ProcessId; temp.DeliveryTermsId = pt.DeliveryTermsId; temp.DocumentPrintReportHeaderId = pt.DocumentPrintReportHeaderId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _SaleDispatchSettingService.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.SaleDispatchSettingId, ActivityType = (int)ActivityTypeContants.SettingsModified, xEModifications = Modifications, })); return(RedirectToAction("Index", "SaleDispatchHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } } //PrepareViewBag(); return(View("Create", vm)); }
public void Update(SaleDispatchSetting pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <SaleDispatchSetting>().Update(pt); }
public SaleDispatchSetting Create(SaleDispatchSetting pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <SaleDispatchSetting>().Insert(pt); return(pt); }
public void Delete(SaleDispatchSetting pt) { _unitOfWork.Repository <SaleDispatchSetting>().Delete(pt); }
public SaleDispatchSetting Add(SaleDispatchSetting pt) { _unitOfWork.Repository <SaleDispatchSetting>().Insert(pt); return(pt); }