private OptionSelectionList ParseSelections(Product p) { OptionSelectionList result = new OptionSelectionList(); foreach (Option opt in p.Options) { // No need to parse HTML or Input Fields as they do not affect the ajax // updates on products if (opt.OptionType == OptionTypes.Html || opt.OptionType == OptionTypes.TextInput || opt.OptionType == OptionTypes.FileUpload) { continue; } string strippeddata = Request.Form["opt" + opt.Bvin.Replace("-", "")]; // stuff value into a guid to restore dashes which are invalid for // asp.net control ids if (strippeddata == "" || strippeddata == "undefined" || strippeddata == null) { continue; } else { System.Guid g = System.Guid.NewGuid(); if (System.Guid.TryParse(strippeddata, out g)) { result.Add(new OptionSelection(opt.Bvin, g.ToString())); } else { result.Add(new OptionSelection(opt.Bvin, strippeddata)); } } } return(result); }
private void ParseSelections(ProductPageViewModel model) { OptionSelectionList result = new OptionSelectionList(); foreach (Option opt in model.LocalProduct.Options) { OptionSelection selected = opt.ParseFromForm(Request.Form); if (selected != null) { result.Add(selected); } } model.Selections = result; }
private OptionSelectionList ParseSelections(Product p) { OptionSelectionList result = new OptionSelectionList(); foreach (Option opt in p.Options) { OptionSelection selected = opt.ParseFromPlaceholder(this.phChoices); if (selected != null) { result.Add(selected); } } return(result); }
private OptionSelectionList ParseSelections(Product p) { OptionSelectionList result = new OptionSelectionList(); foreach (Option opt in p.Options) { // No need to parse HTML or Input Fields as they do not affect the ajax // updates on products if (opt.OptionType == OptionTypes.Html || opt.OptionType == OptionTypes.TextInput || opt.OptionType == OptionTypes.FileUpload) { continue; } string strippeddata = Request.Form["opt" + opt.Bvin.Replace("-", "")]; // stuff value into a guid to restore dashes which are invalid for // asp.net control ids if (strippeddata == "" || strippeddata == "undefined" || strippeddata == null) { continue; } else { System.Guid g = System.Guid.NewGuid(); if (System.Guid.TryParse(strippeddata, out g)) { result.Add(new OptionSelection(opt.Bvin, g.ToString())); } else { result.Add(new OptionSelection(opt.Bvin, strippeddata)); } } } return result; }
// Loop through all possible variants and generate selection data private void GenerateVariantSelections(List<OptionSelectionList> data, List<Option> options, int optionIndex, OptionSelectionList tempSelections) { if (optionIndex > (options.Count - 1)) { // we've hit all options so add the selections to the data OptionSelectionList temp = new OptionSelectionList(); temp.AddRange(tempSelections); //tempSelections.RemoveAt(tempSelections.Count() - 1); //tempSelections.Clear(); data.Add(temp); } else { Option opt = options[optionIndex]; foreach (OptionItem oi in opt.Items) { if (oi.IsLabel == false) { OptionSelectionList localList = new OptionSelectionList(); localList.AddRange(tempSelections); localList.Add(new OptionSelection(opt.Bvin, oi.Bvin)); GenerateVariantSelections(data, options, optionIndex + 1, localList); } } } }
private OptionSelectionList ParseSelections(Product p) { OptionSelectionList result = new OptionSelectionList(); foreach (Option opt in p.Options) { OptionSelection selected = opt.ParseFromPlaceholder(this.phChoices); if (selected != null) { result.Add(selected); } } return result; }