private static Manufacturer DBMapping(DBManufacturer dbItem) { if (dbItem == null) return null; Manufacturer item = new Manufacturer(); item.ManufacturerID = dbItem.ManufacturerID; item.Name = dbItem.Name; item.Description = dbItem.Description; item.TemplateID = dbItem.TemplateID; item.MetaKeywords = dbItem.MetaKeywords; item.MetaDescription = dbItem.MetaDescription; item.MetaTitle = dbItem.MetaTitle; item.SEName = dbItem.SEName; item.PictureID = dbItem.PictureID; item.PageSize = dbItem.PageSize; item.PriceRanges = dbItem.PriceRanges; item.Published = dbItem.Published; item.Deleted = dbItem.Deleted; item.DisplayOrder = dbItem.DisplayOrder; item.CreatedOn = dbItem.CreatedOn; item.UpdatedOn = dbItem.UpdatedOn; return item; }
private void CreateChildControlsTree() { manufacturer = ManufacturerManager.GetManufacturerById(this.ManufacturerId); if (manufacturer != null) { Control child = null; var manufacturerTemplate = manufacturer.ManufacturerTemplate; if (manufacturerTemplate == null) throw new NopException(string.Format("Manufacturer template path can not be empty. ManufacturerID={0}", manufacturer.ManufacturerId)); child = base.LoadControl(manufacturerTemplate.TemplatePath); this.ManufacturerPlaceHolder.Controls.Add(child); } }
/// <summary> /// Gets manufacturer URL /// </summary> /// <param name="manufacturer">Manufacturer</param> /// <returns>Manufacturer URL</returns> public static string GetManufacturerUrl(Manufacturer manufacturer) { if (manufacturer == null) throw new ArgumentNullException("manufacturer"); string seName = GetManufacturerSEName(manufacturer); string url2 = SEOHelper.EnableUrlRewriting ? IoC.Resolve<ISettingManager>().GetSettingValue("SEO.Manufacturer.UrlRewriteFormat") : "{0}Manufacturer.aspx?ManufacturerID={1}"; string url = string.Format(url2, CommonHelper.GetStoreLocation(), manufacturer.ManufacturerId, seName); return url.ToLowerInvariant(); }
/// <summary> /// Gets manufacturer SE (search engine) name /// </summary> /// <param name="manufacturer">Manufacturer</param> /// <returns>Manufacturer SE (search engine) name</returns> public static string GetManufacturerSEName(Manufacturer manufacturer) { if (manufacturer == null) throw new ArgumentNullException("manufacturer"); string seName = GetSEName(manufacturer.SEName); if (String.IsNullOrEmpty(seName)) { seName = GetSEName(manufacturer.Name); } return seName; }
protected void SaveLocalizableContent(Manufacturer manufacturer) { if (manufacturer == null) return; if (!this.HasLocalizableContent) return; foreach (RepeaterItem item in rptrLanguageDivs.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedMetaKeywords = (TextBox)item.FindControl("txtLocalizedMetaKeywords"); var txtLocalizedMetaDescription = (TextBox)item.FindControl("txtLocalizedMetaDescription"); var txtLocalizedMetaTitle = (TextBox)item.FindControl("txtLocalizedMetaTitle"); var txtLocalizedSEName = (TextBox)item.FindControl("txtLocalizedSEName"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string metaKeywords = txtLocalizedMetaKeywords.Text; string metaDescription = txtLocalizedMetaDescription.Text; string metaTitle = txtLocalizedMetaTitle.Text; string seName = txtLocalizedSEName.Text; bool allFieldsAreEmpty = (string.IsNullOrEmpty(metaKeywords) && string.IsNullOrEmpty(metaDescription) && string.IsNullOrEmpty(metaTitle) && string.IsNullOrEmpty(seName)); var content = ManufacturerManager.GetManufacturerLocalizedByManufacturerIdAndLanguageId(manufacturer.ManufacturerId, languageId); if (content == null) { if (!allFieldsAreEmpty && languageId > 0) { //only insert if one of the fields are filled out (avoid too many empty records in db...) content = ManufacturerManager.InsertManufacturerLocalized(manufacturer.ManufacturerId, languageId, string.Empty, string.Empty, metaKeywords, metaDescription, metaTitle, seName); } } else { if (languageId > 0) { content = ManufacturerManager.UpdateManufacturerLocalized(content.ManufacturerLocalizedId, content.ManufacturerId, languageId, content.Name, content.Description, metaKeywords, metaDescription, metaTitle, seName); } } } } }
private void CreateChildControlsTree() { string manufacturerName = string.Empty; //NFF - removed for URL route project. //manufacturer = this.ManufacturerService.GetManufacturerById(this.ManufacturerId); if (Page.RouteData.Values["SellerName"] != null) { manufacturerName = Page.RouteData.Values["SellerName"].ToString(); } manufacturer = this.ManufacturerService.GetManufacturerByTrimName(manufacturerName); if (manufacturer != null) { Control child = null; var manufacturerTemplate = manufacturer.ManufacturerTemplate; if (manufacturerTemplate == null) throw new NopException(string.Format("Manufacturer template path can not be empty. ManufacturerID={0}", manufacturer.ManufacturerId)); child = base.LoadControl(manufacturerTemplate.TemplatePath); this.ManufacturerPlaceHolder.Controls.Add(child); } }
public Manufacturer SaveInfo() { var manufacturer = this.ManufacturerService.GetManufacturerById(this.ManufacturerId); var vendor = this.VendorService.GetVendor(NopCommerce.BusinessLogic.NopContext.Current.User.Vendor.CustomerId); if (manufacturer != null) { Picture manufacturerPicture = manufacturer.Picture; HttpPostedFile manufacturerPictureFile = fuManufacturerPicture.PostedFile; if ((manufacturerPictureFile != null) && (!String.IsNullOrEmpty(manufacturerPictureFile.FileName))) { byte[] manufacturerPictureBinary = manufacturerPictureFile.GetPictureBits(); if (manufacturerPicture != null) manufacturerPicture = this.PictureService.UpdatePicture(manufacturerPicture.PictureId, manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); else manufacturerPicture = this.PictureService.InsertPicture(manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } int manufacturerPictureId = 0; if (manufacturerPicture != null) manufacturerPictureId = manufacturerPicture.PictureId; manufacturer.Name = txtName.Text; vendor.CompanyName = txtName.Text; manufacturer.Description = txtDescription.Value; manufacturer.TemplateId = 1;// int.Parse(this.ddlTemplate.SelectedItem.Value); manufacturer.PictureId = manufacturerPictureId; manufacturer.PriceRanges = String.Empty;// txtPriceRanges.Text; manufacturer.Published = true;// cbPublished.Checked; manufacturer.DisplayOrder = 0;// txtDisplayOrder.Value; manufacturer.UpdatedOn = DateTime.UtcNow; manufacturer.SEName = txtName.Text; manufacturer.MetaDescription = txtDescription.Value; this.ManufacturerService.UpdateManufacturer(manufacturer); this.VendorService.UpdateVendor(vendor); } else { Picture manufacturerPicture = null; HttpPostedFile manufacturerPictureFile = fuManufacturerPicture.PostedFile; if ((manufacturerPictureFile != null) && (!String.IsNullOrEmpty(manufacturerPictureFile.FileName))) { byte[] manufacturerPictureBinary = manufacturerPictureFile.GetPictureBits(); manufacturerPicture = this.PictureService.InsertPicture(manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } int manufacturerPictureId = 0; if (manufacturerPicture != null) manufacturerPictureId = manufacturerPicture.PictureId; DateTime nowDt = DateTime.UtcNow; manufacturer = new Manufacturer() { Name = txtName.Text, Description = txtDescription.Value, TemplateId = 1,//int.Parse(this.ddlTemplate.SelectedItem.Value), PictureId = manufacturerPictureId, PageSize = 10, PriceRanges = String.Empty,//txtPriceRanges.Text, Published = true, //cbPublished.Checked, DisplayOrder = 0, //txtDisplayOrder.Value, CreatedOn = nowDt, UpdatedOn = nowDt }; this.ManufacturerService.InsertManufacturer(manufacturer); } SaveLocalizableContent(manufacturer); return manufacturer; }
protected void SaveLocalizableContent(Manufacturer manufacturer) { if (manufacturer == null) return; if (!this.HasLocalizableContent) return; foreach (RepeaterItem item in rptrLanguageDivs.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedName = (TextBox)item.FindControl("txtLocalizedName"); var txtLocalizedDescription = (FCKeditor)item.FindControl("txtLocalizedDescription"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string name = txtLocalizedName.Text; string description = txtLocalizedDescription.Value; bool allFieldsAreEmpty = (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(description)); var content = this.ManufacturerService.GetManufacturerLocalizedByManufacturerIdAndLanguageId(manufacturer.ManufacturerId, languageId); if (content == null) { if (!allFieldsAreEmpty && languageId > 0) { //only insert if one of the fields are filled out (avoid too many empty records in db...) content = new ManufacturerLocalized() { ManufacturerId = manufacturer.ManufacturerId, LanguageId = languageId, Name = name, Description = description }; this.ManufacturerService.InsertManufacturerLocalized(content); } } else { if (languageId > 0) { content.LanguageId = languageId; content.Name = name; content.Description = description; this.ManufacturerService.UpdateManufacturerLocalized(content); } } } } }
protected void SaveLocalizableContent(Manufacturer manufacturer) { if (manufacturer == null) return; if (!this.HasLocalizableContent) return; foreach (RepeaterItem item in rptrLanguageDivs.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { var txtLocalizedMetaKeywords = (TextBox)item.FindControl("txtLocalizedMetaKeywords"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string metaKeywords = txtLocalizedMetaKeywords.Text; bool allFieldsAreEmpty = (string.IsNullOrEmpty(metaKeywords)); var content = this.ManufacturerService.GetManufacturerLocalizedByManufacturerIdAndLanguageId(manufacturer.ManufacturerId, languageId); if (content == null) { if (!allFieldsAreEmpty && languageId > 0) { //only insert if one of the fields are filled out (avoid too many empty records in db...) content = new ManufacturerLocalized() { ManufacturerId = manufacturer.ManufacturerId, LanguageId = languageId, MetaKeywords = metaKeywords }; this.ManufacturerService.InsertManufacturerLocalized(content); } } else { if (languageId > 0) { content.LanguageId = languageId; content.MetaKeywords = metaKeywords; this.ManufacturerService.UpdateManufacturerLocalized(content); } } } } }
/// <summary> /// Gets manufacturer URL /// </summary> /// <param name="manufacturer">Manufacturer</param> /// <returns>Manufacturer URL</returns> public static string GetManufacturerURL(Manufacturer manufacturer) { if (manufacturer == null) throw new ArgumentNullException("manufacturer"); string seName = GetSEName(manufacturer.SEName); if (String.IsNullOrEmpty(seName)) { seName = GetSEName(manufacturer.Name); } string url = string.Format(SettingManager.GetSettingValue("SEO.Manufacturer.UrlRewriteFormat"), CommonHelper.GetStoreLocation(), manufacturer.ManufacturerID, seName); return url; }
/// <summary> /// Updates the manufacturer /// </summary> /// <param name="manufacturer">Manufacturer</param> public void UpdateManufacturer(Manufacturer manufacturer) { if (manufacturer == null) throw new ArgumentNullException("manufacturer"); manufacturer.Name = CommonHelper.EnsureNotNull(manufacturer.Name); manufacturer.Name = CommonHelper.EnsureMaximumLength(manufacturer.Name, 400); manufacturer.Description = CommonHelper.EnsureNotNull(manufacturer.Description); manufacturer.MetaKeywords = CommonHelper.EnsureNotNull(manufacturer.MetaKeywords); manufacturer.MetaKeywords = CommonHelper.EnsureMaximumLength(manufacturer.MetaKeywords, 400); manufacturer.MetaDescription = CommonHelper.EnsureNotNull(manufacturer.MetaDescription); manufacturer.MetaDescription = CommonHelper.EnsureMaximumLength(manufacturer.MetaDescription, 4000); manufacturer.MetaTitle = CommonHelper.EnsureNotNull(manufacturer.MetaTitle); manufacturer.MetaTitle = CommonHelper.EnsureMaximumLength(manufacturer.MetaTitle, 400); manufacturer.SEName = CommonHelper.EnsureNotNull(manufacturer.SEName); manufacturer.SEName = CommonHelper.EnsureMaximumLength(manufacturer.SEName, 100); manufacturer.PriceRanges = CommonHelper.EnsureNotNull(manufacturer.PriceRanges); manufacturer.PriceRanges = CommonHelper.EnsureMaximumLength(manufacturer.PriceRanges, 400); if (!_context.IsAttached(manufacturer)) _context.Manufacturers.Attach(manufacturer); _context.SaveChanges(); if (this.ManufacturersCacheEnabled || this.MappingsCacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY); _cacheManager.RemoveByPattern(PRODUCTMANUFACTURERS_PATTERN_KEY); } }
public Manufacturer SaveInfo() { var manufacturer = this.ManufacturerService.GetManufacturerById(this.ManufacturerId); if (manufacturer != null) { Picture manufacturerPicture = manufacturer.Picture; HttpPostedFile manufacturerPictureFile = fuManufacturerPicture.PostedFile; if ((manufacturerPictureFile != null) && (!String.IsNullOrEmpty(manufacturerPictureFile.FileName))) { byte[] manufacturerPictureBinary = manufacturerPictureFile.GetPictureBits(); if (manufacturerPicture != null) manufacturerPicture = this.PictureService.UpdatePicture(manufacturerPicture.PictureId, manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); else manufacturerPicture = this.PictureService.InsertPicture(manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } int manufacturerPictureId = 0; if (manufacturerPicture != null) manufacturerPictureId = manufacturerPicture.PictureId; manufacturer.Name = txtName.Text; manufacturer.Description = txtDescription.Value; manufacturer.TemplateId = int.Parse(this.ddlTemplate.SelectedItem.Value); manufacturer.PictureId = manufacturerPictureId; manufacturer.PriceRanges = txtPriceRanges.Text; manufacturer.Published = cbPublished.Checked; manufacturer.DisplayOrder = txtDisplayOrder.Value; manufacturer.UpdatedOn = DateTime.UtcNow; this.ManufacturerService.UpdateManufacturer(manufacturer); } else { Picture manufacturerPicture = null; HttpPostedFile manufacturerPictureFile = fuManufacturerPicture.PostedFile; if ((manufacturerPictureFile != null) && (!String.IsNullOrEmpty(manufacturerPictureFile.FileName))) { byte[] manufacturerPictureBinary = manufacturerPictureFile.GetPictureBits(); manufacturerPicture = this.PictureService.InsertPicture(manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } int manufacturerPictureId = 0; if (manufacturerPicture != null) manufacturerPictureId = manufacturerPicture.PictureId; DateTime nowDt = DateTime.UtcNow; manufacturer = new Manufacturer() { Name = txtName.Text, Description = txtDescription.Value, TemplateId = int.Parse(this.ddlTemplate.SelectedItem.Value), PictureId = manufacturerPictureId, PageSize = 10, PriceRanges = txtPriceRanges.Text, Published = cbPublished.Checked, DisplayOrder = txtDisplayOrder.Value, CreatedOn = nowDt, UpdatedOn = nowDt }; this.ManufacturerService.InsertManufacturer(manufacturer); } SaveLocalizableContent(manufacturer); return manufacturer; }