private static Pricelist DBMapping(DBPricelist dbItem) { if (dbItem == null) return null; Pricelist item = new Pricelist(); item.PricelistID = dbItem.PricelistID; item.ExportModeID = dbItem.ExportModeID; item.ExportTypeID = dbItem.ExportTypeID; item.AffiliateID = dbItem.AffiliateID; item.DisplayName = dbItem.DisplayName; item.ShortName = dbItem.ShortName; item.PricelistGuid = dbItem.PricelistGuid; item.CacheTime = dbItem.CacheTime; item.FormatLocalization = dbItem.FormatLocalization; item.Description = dbItem.Description; item.AdminNotes = dbItem.AdminNotes; item.Header = dbItem.Header; item.Body = dbItem.Body; item.Footer = dbItem.Footer; item.PriceAdjustment = dbItem.PriceAdjustment; item.PriceAdjustmentTypeID = dbItem.PriceAdjustmentTypeID; item.OverrideIndivAdjustment = dbItem.OverrideIndivAdjustment; item.CreatedOn = dbItem.CreatedOn; item.UpdatedOn = dbItem.UpdatedOn; return item; }
/// <summary> /// Updates the Pricelist /// </summary> /// <param name="pricelist">Pricelist</param> public void UpdatePricelist(Pricelist pricelist) { if (pricelist == null) throw new ArgumentNullException("pricelist"); pricelist.DisplayName = CommonHelper.EnsureNotNull(pricelist.DisplayName); pricelist.DisplayName = CommonHelper.EnsureMaximumLength(pricelist.DisplayName, 100); pricelist.ShortName = CommonHelper.EnsureNotNull(pricelist.ShortName); pricelist.ShortName = CommonHelper.EnsureMaximumLength(pricelist.ShortName, 20); pricelist.PricelistGuid = CommonHelper.EnsureNotNull(pricelist.PricelistGuid); pricelist.PricelistGuid = CommonHelper.EnsureMaximumLength(pricelist.PricelistGuid, 40); pricelist.FormatLocalization = CommonHelper.EnsureNotNull(pricelist.FormatLocalization); pricelist.FormatLocalization = CommonHelper.EnsureMaximumLength(pricelist.FormatLocalization, 5); pricelist.Description = CommonHelper.EnsureNotNull(pricelist.Description); pricelist.Description = CommonHelper.EnsureMaximumLength(pricelist.Description, 500); pricelist.AdminNotes = CommonHelper.EnsureNotNull(pricelist.AdminNotes); pricelist.AdminNotes = CommonHelper.EnsureMaximumLength(pricelist.AdminNotes, 500); pricelist.Header = CommonHelper.EnsureNotNull(pricelist.Header); pricelist.Header = CommonHelper.EnsureMaximumLength(pricelist.Header, 500); pricelist.Body = CommonHelper.EnsureNotNull(pricelist.Body); pricelist.Body = CommonHelper.EnsureMaximumLength(pricelist.Body, 500); pricelist.Footer = CommonHelper.EnsureNotNull(pricelist.Footer); pricelist.Footer = CommonHelper.EnsureMaximumLength(pricelist.Footer, 500); if (!_context.IsAttached(pricelist)) _context.Pricelists.Attach(pricelist); _context.SaveChanges(); }
public Pricelist SaveInfo() { int affiliateId = int.Parse(ddlAffiliate.SelectedValue); PriceListExportModeEnum exportMode = (PriceListExportModeEnum)Enum.ToObject(typeof(PriceListExportModeEnum), int.Parse(this.ddlExportMode.SelectedItem.Value)); PriceListExportTypeEnum exportType = (PriceListExportTypeEnum)Enum.ToObject(typeof(PriceListExportTypeEnum), int.Parse(this.ddlExportType.SelectedItem.Value)); PriceAdjustmentTypeEnum priceAdjustmentType = (PriceAdjustmentTypeEnum)Enum.ToObject(typeof(PriceAdjustmentTypeEnum), int.Parse(this.ddlPriceAdjustmentType.SelectedItem.Value)); decimal priceAdjustment = txtPriceAdjustment.Value; Pricelist pricelist = this.ProductService.GetPricelistById(this.PricelistId); if (pricelist != null) { pricelist.ExportModeId = (int)exportMode; pricelist.ExportTypeId = (int)exportType; pricelist.AffiliateId = affiliateId; pricelist.DisplayName = this.txtDisplayName.Text; pricelist.ShortName = this.txtShortName.Text; pricelist.PricelistGuid = this.txtPricelistGuid.Text; pricelist.CacheTime = this.txtCacheTime.Value; pricelist.FormatLocalization = this.ddlFormatLocalization.SelectedValue; pricelist.Description = this.txtDescription.Text; pricelist.AdminNotes = this.txtAdminNotes.Text; pricelist.Header = this.txtHeader.Text; pricelist.Body = this.txtBody.Text; pricelist.Footer = this.txtFooter.Text; pricelist.PriceAdjustmentTypeId = (int)priceAdjustmentType; pricelist.PriceAdjustment = priceAdjustment; pricelist.OverrideIndivAdjustment = chkOverrideIndivAdjustment.Checked; pricelist.UpdatedOn = DateTime.UtcNow; this.ProductService.UpdatePricelist(pricelist); SavePricelistChanges(pricelist.PricelistId); } else { pricelist = new Pricelist(); pricelist.ExportModeId = (int)exportMode; pricelist.ExportTypeId = (int)exportType; pricelist.AffiliateId = affiliateId; pricelist.DisplayName = this.txtDisplayName.Text; pricelist.ShortName = this.txtShortName.Text; pricelist.PricelistGuid = this.txtPricelistGuid.Text; pricelist.CacheTime = this.txtCacheTime.Value; pricelist.FormatLocalization = this.ddlFormatLocalization.SelectedValue; pricelist.Description = this.txtDescription.Text; pricelist.AdminNotes = this.txtAdminNotes.Text; pricelist.Header = this.txtHeader.Text; pricelist.Body = this.txtBody.Text; pricelist.Footer = this.txtFooter.Text; pricelist.PriceAdjustmentTypeId = (int)priceAdjustmentType; pricelist.PriceAdjustment = priceAdjustment; pricelist.OverrideIndivAdjustment = chkOverrideIndivAdjustment.Checked; pricelist.CreatedOn = DateTime.UtcNow; pricelist.UpdatedOn = DateTime.UtcNow; this.ProductService.InsertPricelist(pricelist); SavePricelistChanges(pricelist.PricelistId); } return pricelist; }