protected void AddButton_Click(object sender, EventArgs e) { if (Page.IsValid) { Option option = new Option(); option.Name = AddOptionName.Text; option.CreatedDate = LocaleHelper.LocalNow; string[] choices = AddOptionChoices.Text.Split(",".ToCharArray()); foreach (string item in choices) { string choiceName = item.Trim(); if (choiceName != String.Empty) { OptionChoice choice = new OptionChoice(); choice.Option = option; choice.Name = StringHelper.Truncate(choiceName, 50); choice.OrderBy = -1; option.Choices.Add(choice); } } option.Save(); ProductOption productOption = new ProductOption(_Product, option, -1); productOption.Save(); // RESET VARIANT GRID FOR THE ASSOCIATED PRODUCT ProductVariantManager.ResetVariantGrid(_Product.Id); option.ProductOptions.Add(productOption); _Options.Add(option); AddOptionName.Text = string.Empty; AddOptionChoices.Text = string.Empty; BindOptionsGrid(); } }
/// <summary> /// Deletes this ProductOption object from the database /// </summary> /// <returns><b>true</b> if delete successful, <b>false</b> otherwise.</returns> public virtual bool Delete() { bool result = this.BaseDelete(); OptionDataSource.DeleteOrphanedOptions(); //REBUILD VARIANT GRID FOR THIS PRODUCT ProductVariantManager.ResetVariantGrid(this.ProductId); return(result); }
/// <summary> /// Saves this ProductOption object to the database /// </summary> /// <returns><b>SaveResult</b> enumeration that represents the result of the save operation.</returns> public virtual SaveResult Save() { SaveResult baseResult = this.BaseSave(); if (baseResult == SaveResult.RecordInserted) { //REBUILD VARIANT GRID FOR THIS PRODUCT ProductVariantManager.ResetVariantGrid(this.ProductId); } return(baseResult); }