public ActionResult Post(PurchaseInvoiceSettingsViewModel vm) { PurchaseInvoiceSetting pt = AutoMapper.Mapper.Map <PurchaseInvoiceSettingsViewModel, PurchaseInvoiceSetting>(vm); if (ModelState.IsValid) { if (vm.PurchaseInvoiceSettingId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _PurchaseInvoiceSettingService.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.PurchaseInvoiceSettingId, ActivityType = (int)ActivityTypeContants.SettingsAdded, })); return(RedirectToAction("Index", "PurchaseInvoiceHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); PurchaseInvoiceSetting temp = _PurchaseInvoiceSettingService.Find(pt.PurchaseInvoiceSettingId); PurchaseInvoiceSetting ExRec = Mapper.Map <PurchaseInvoiceSetting>(temp); temp.filterContraDocTypes = pt.filterContraDocTypes; temp.filterLedgerAccountGroups = pt.filterLedgerAccountGroups; temp.filterLedgerAccounts = pt.filterLedgerAccounts; temp.filterProductGroups = pt.filterProductGroups; temp.filterProducts = pt.filterProducts; temp.filterProductTypes = pt.filterProductTypes; temp.isEditableRate = pt.isEditableRate; temp.isMandatoryCostCenter = pt.isMandatoryCostCenter; temp.isMandatoryRate = pt.isMandatoryRate; temp.filterContraDivisions = pt.filterContraDivisions; temp.filterContraSites = pt.filterContraSites; temp.CalculationId = pt.CalculationId; 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.SqlProcDocumentPrint_AfterApprove = pt.SqlProcDocumentPrint_AfterApprove; temp.SqlProcDocumentPrint_AfterSubmit = pt.SqlProcDocumentPrint_AfterSubmit; temp.CalculateDiscountOnRate = pt.CalculateDiscountOnRate; temp.UnitConversionForId = pt.UnitConversionForId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _PurchaseInvoiceSettingService.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.PurchaseInvoiceSettingId, ActivityType = (int)ActivityTypeContants.SettingsModified, xEModifications = Modifications, })); return(RedirectToAction("Index", "PurchaseInvoiceHeader", new { id = vm.DocTypeId }).Success("Data saved successfully")); } } //PrepareViewBag(); return(View("Create", vm)); }
public void Update(PurchaseInvoiceSetting pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <PurchaseInvoiceSetting>().Update(pt); }
public PurchaseInvoiceSetting Create(PurchaseInvoiceSetting pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <PurchaseInvoiceSetting>().Insert(pt); return(pt); }
public void Delete(PurchaseInvoiceSetting pt) { _unitOfWork.Repository <PurchaseInvoiceSetting>().Delete(pt); }
public PurchaseInvoiceSetting Add(PurchaseInvoiceSetting pt) { _unitOfWork.Repository <PurchaseInvoiceSetting>().Insert(pt); return(pt); }