Ejemplo n.º 1
0
        public PartialViewResult AddOption(ProductOptionsViewModel productOptionViewModel, string optionName, Guid prodId)
        {
            Product         selectedProduct = EntityRepository.Products.Where(p => p.ProductId == prodId).FirstOrDefault();
            TemplateOptions selectedOption  = EntityRepository.TemplateOptions.Where(t => t.OptionName == optionName).FirstOrDefault();

            ProductOptionDetails option = new ProductOptionDetails
            {
                OptionId         = Guid.NewGuid(),
                OptionName       = selectedOption.OptionName,
                OptionType       = selectedOption.OptionType,
                ParentOptionList = new SelectList(selectedProduct.ProductOptions.Select(o => o.OptionName), "Empty"),
                ParamList        = new SelectList(selectedOption.TempOptionParams.Select(p => p.ParameterName), "Empty"),
            };

            foreach (var param in selectedOption.TempOptionParams)
            {
                ProductOptionDetails.ProductOptionParamsDetails optionParams = new ProductOptionDetails.ProductOptionParamsDetails
                {
                    ParameterId     = Guid.NewGuid(),
                    Paramname       = param.ParameterName,
                    ParamTooltip    = param.ParameterTooltip,
                    ParamPrice      = param.ParameterPrice,
                    Sale            = param.ParameterSale,
                    ParamParentList = new SelectList(Enumerable.Empty <SelectListItem>())
                };
                if (option.ParamCollection is null)
                {
                    option.ParamCollection = new List <ProductOptionDetails.ProductOptionParamsDetails>();
                }
                option.ParamCollection.Add(optionParams);
            }

            return(PartialView("~/Views/Shared/EditorTemplates/ProductOptionDetails.cshtml", option));
        }
Ejemplo n.º 2
0
        public PartialViewResult AddParam(string optionName, string paramName)
        {
            TempOptionParams TempOptionParams = EntityRepository.TemplateOptions.Where(po => po.OptionName == optionName)?.Select(p => p.TempOptionParams.Where(par => par.ParameterName == paramName).FirstOrDefault()).FirstOrDefault();

            ProductOptionDetails.ProductOptionParamsDetails parameter = new ProductOptionDetails.ProductOptionParamsDetails
            {
                ParameterId  = Guid.NewGuid(),
                Paramname    = TempOptionParams?.ParameterName,
                ParamTooltip = TempOptionParams?.ParameterTooltip,
                ParamPrice   = TempOptionParams?.ParameterPrice ?? Decimal.Zero,
                Sale         = TempOptionParams?.ParameterSale
            };
            return(PartialView("~/Views/Shared/EditorTemplates/ProductOptionParamsDetails.cshtml", parameter));
        }