protected void SaveLocalizableContent(CheckoutAttribute checkoutAttribute) { if (checkoutAttribute == 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 txtLocalizedTextPrompt = (TextBox)item.FindControl("txtLocalizedTextPrompt"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string name = txtLocalizedName.Text; string textPrompt = txtLocalizedTextPrompt.Text; bool allFieldsAreEmpty = (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(textPrompt)); var content = this.CheckoutAttributeService.GetCheckoutAttributeLocalizedByCheckoutAttributeIdAndLanguageId(checkoutAttribute.CheckoutAttributeId, 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 CheckoutAttributeLocalized() { CheckoutAttributeId = checkoutAttribute.CheckoutAttributeId, LanguageId = languageId, Name = name, TextPrompt = textPrompt }; this.CheckoutAttributeService.InsertCheckoutAttributeLocalized(content); } } else { if (languageId > 0) { content.LanguageId = languageId; content.Name = name; content.TextPrompt = textPrompt; this.CheckoutAttributeService.UpdateCheckoutAttributeLocalized(content); } } } } }
protected void SaveLocalizableContent(CheckoutAttribute checkoutAttribute) { if (checkoutAttribute == 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 txtLocalizedTextPrompt = (TextBox)item.FindControl("txtLocalizedTextPrompt"); var lblLanguageId = (Label)item.FindControl("lblLanguageId"); int languageId = int.Parse(lblLanguageId.Text); string name = txtLocalizedName.Text; string textPrompt = txtLocalizedTextPrompt.Text; bool allFieldsAreEmpty = (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(textPrompt)); var content = this.CheckoutAttributeService.GetCheckoutAttributeLocalizedByCheckoutAttributeIdAndLanguageId(checkoutAttribute.CheckoutAttributeId, 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 CheckoutAttributeLocalized() { CheckoutAttributeId = checkoutAttribute.CheckoutAttributeId, LanguageId = languageId, Name = name, TextPrompt = textPrompt }; this.CheckoutAttributeService.InsertCheckoutAttributeLocalized(content); } } else { if (languageId > 0) { content.LanguageId= languageId; content.Name= name; content.TextPrompt= textPrompt; this.CheckoutAttributeService.UpdateCheckoutAttributeLocalized(content); } } } } }