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); } } } } }