/// <summary> /// Inserts a localized manufacturer /// </summary> /// <param name="manufacturerLocalized">Manufacturer content</param> public void InsertManufacturerLocalized(ManufacturerLocalized manufacturerLocalized) { if (manufacturerLocalized == null) { throw new ArgumentNullException("manufacturerLocalized"); } manufacturerLocalized.Name = CommonHelper.EnsureNotNull(manufacturerLocalized.Name); manufacturerLocalized.Name = CommonHelper.EnsureMaximumLength(manufacturerLocalized.Name, 400); manufacturerLocalized.Description = CommonHelper.EnsureNotNull(manufacturerLocalized.Description); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaKeywords); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaKeywords, 400); manufacturerLocalized.MetaDescription = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaDescription); manufacturerLocalized.MetaDescription = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaDescription, 4000); manufacturerLocalized.MetaTitle = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaTitle); manufacturerLocalized.MetaTitle = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaTitle, 400); manufacturerLocalized.SEName = CommonHelper.EnsureNotNull(manufacturerLocalized.SEName); manufacturerLocalized.SEName = CommonHelper.EnsureMaximumLength(manufacturerLocalized.SEName, 100); _context.ManufacturerLocalized.AddObject(manufacturerLocalized); _context.SaveChanges(); if (this.ManufacturersCacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY); } }
/// <summary> /// Update a localized manufacturer /// </summary> /// <param name="manufacturerLocalized">Manufacturer content</param> public void UpdateManufacturerLocalized(ManufacturerLocalized manufacturerLocalized) { if (manufacturerLocalized == null) { throw new ArgumentNullException("manufacturerLocalized"); } manufacturerLocalized.Name = CommonHelper.EnsureNotNull(manufacturerLocalized.Name); manufacturerLocalized.Name = CommonHelper.EnsureMaximumLength(manufacturerLocalized.Name, 400); manufacturerLocalized.Description = CommonHelper.EnsureNotNull(manufacturerLocalized.Description); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaKeywords); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaKeywords, 400); manufacturerLocalized.MetaDescription = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaDescription); manufacturerLocalized.MetaDescription = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaDescription, 4000); manufacturerLocalized.MetaTitle = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaTitle); manufacturerLocalized.MetaTitle = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaTitle, 400); manufacturerLocalized.SEName = CommonHelper.EnsureNotNull(manufacturerLocalized.SEName); manufacturerLocalized.SEName = CommonHelper.EnsureMaximumLength(manufacturerLocalized.SEName, 100); bool allFieldsAreEmpty = string.IsNullOrEmpty(manufacturerLocalized.Name) && string.IsNullOrEmpty(manufacturerLocalized.Description) && string.IsNullOrEmpty(manufacturerLocalized.MetaKeywords) && string.IsNullOrEmpty(manufacturerLocalized.MetaDescription) && string.IsNullOrEmpty(manufacturerLocalized.MetaTitle) && string.IsNullOrEmpty(manufacturerLocalized.SEName); if (!_context.IsAttached(manufacturerLocalized)) { _context.ManufacturerLocalized.Attach(manufacturerLocalized); } if (allFieldsAreEmpty) { //delete if all fields are empty _context.DeleteObject(manufacturerLocalized); _context.SaveChanges(); } else { _context.SaveChanges(); } if (this.ManufacturersCacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY); } }
private static ManufacturerLocalized DBMapping(DBManufacturerLocalized dbItem) { if (dbItem == null) { return(null); } var item = new ManufacturerLocalized(); item.ManufacturerLocalizedId = dbItem.ManufacturerLocalizedId; item.ManufacturerId = dbItem.ManufacturerId; item.LanguageId = dbItem.LanguageId; item.Name = dbItem.Name; item.Description = dbItem.Description; item.MetaKeywords = dbItem.MetaKeywords; item.MetaDescription = dbItem.MetaDescription; item.MetaTitle = dbItem.MetaTitle; item.SEName = dbItem.SEName; return(item); }
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 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 = 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, MetaDescription = metaDescription, MetaTitle = metaTitle, SEName = seName }; this.ManufacturerService.InsertManufacturerLocalized(content); } } else { if (languageId > 0) { content.LanguageId = languageId; content.MetaKeywords = metaKeywords; content.MetaDescription = metaDescription; content.MetaTitle = metaTitle; content.SEName = seName; this.ManufacturerService.UpdateManufacturerLocalized(content); } } } } }
/// <summary> /// Update a localized manufacturer /// </summary> /// <param name="manufacturerLocalized">Manufacturer content</param> public void UpdateManufacturerLocalized(ManufacturerLocalized manufacturerLocalized) { if (manufacturerLocalized == null) throw new ArgumentNullException("manufacturerLocalized"); manufacturerLocalized.Name = CommonHelper.EnsureNotNull(manufacturerLocalized.Name); manufacturerLocalized.Name = CommonHelper.EnsureMaximumLength(manufacturerLocalized.Name, 400); manufacturerLocalized.Description = CommonHelper.EnsureNotNull(manufacturerLocalized.Description); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaKeywords); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaKeywords, 400); manufacturerLocalized.MetaDescription = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaDescription); manufacturerLocalized.MetaDescription = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaDescription, 4000); manufacturerLocalized.MetaTitle = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaTitle); manufacturerLocalized.MetaTitle = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaTitle, 400); manufacturerLocalized.SEName = CommonHelper.EnsureNotNull(manufacturerLocalized.SEName); manufacturerLocalized.SEName = CommonHelper.EnsureMaximumLength(manufacturerLocalized.SEName, 100); bool allFieldsAreEmpty = string.IsNullOrEmpty(manufacturerLocalized.Name) && string.IsNullOrEmpty(manufacturerLocalized.Description) && string.IsNullOrEmpty(manufacturerLocalized.MetaKeywords) && string.IsNullOrEmpty(manufacturerLocalized.MetaDescription) && string.IsNullOrEmpty(manufacturerLocalized.MetaTitle) && string.IsNullOrEmpty(manufacturerLocalized.SEName); if (!_context.IsAttached(manufacturerLocalized)) _context.ManufacturerLocalized.Attach(manufacturerLocalized); if (allFieldsAreEmpty) { //delete if all fields are empty _context.DeleteObject(manufacturerLocalized); _context.SaveChanges(); } else { _context.SaveChanges(); } if (this.ManufacturersCacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY); } }
/// <summary> /// Inserts a localized manufacturer /// </summary> /// <param name="manufacturerLocalized">Manufacturer content</param> public void InsertManufacturerLocalized(ManufacturerLocalized manufacturerLocalized) { if (manufacturerLocalized == null) throw new ArgumentNullException("manufacturerLocalized"); manufacturerLocalized.Name = CommonHelper.EnsureNotNull(manufacturerLocalized.Name); manufacturerLocalized.Name = CommonHelper.EnsureMaximumLength(manufacturerLocalized.Name, 400); manufacturerLocalized.Description = CommonHelper.EnsureNotNull(manufacturerLocalized.Description); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaKeywords); manufacturerLocalized.MetaKeywords = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaKeywords, 400); manufacturerLocalized.MetaDescription = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaDescription); manufacturerLocalized.MetaDescription = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaDescription, 4000); manufacturerLocalized.MetaTitle = CommonHelper.EnsureNotNull(manufacturerLocalized.MetaTitle); manufacturerLocalized.MetaTitle = CommonHelper.EnsureMaximumLength(manufacturerLocalized.MetaTitle, 400); manufacturerLocalized.SEName = CommonHelper.EnsureNotNull(manufacturerLocalized.SEName); manufacturerLocalized.SEName = CommonHelper.EnsureMaximumLength(manufacturerLocalized.SEName, 100); _context.ManufacturerLocalized.AddObject(manufacturerLocalized); _context.SaveChanges(); if (this.ManufacturersCacheEnabled) { _cacheManager.RemoveByPattern(MANUFACTURERS_PATTERN_KEY); } }