예제 #1
0
        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();
            }
        }
예제 #2
0
        public void UpdateOption(Guid id, ProductOption option)
        {
            var updatedOption = new ProductOption(id).Update(option);

            if (!updatedOption.IsNew)
            {
                updatedOption.Save();
            }
        }
        public void CreateOption(Guid productId, ProductOption option)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            option.ProductId = productId;
            option.Save();
        }
예제 #4
0
        public void UpdateOption(Guid id, ProductOption option)
        {
            var orig = new ProductOption(id)
            {
                Name        = option.Name,
                Description = option.Description
            };

            orig.Save();
        }
예제 #5
0
        public void ProductOption_UpdateProductOption_ReturnsTrue()
        {
            var ProductOption = new ProductOption
            {
                ProductId   = product.Id,
                Name        = "Red Phone",
                Description = "This is a Red Samsung phone"
            };
            var result = ProductOption.Save();

            Assert.IsTrue(result);

            ProductOption.Name        = "Green Phone";
            ProductOption.Description = "Testing the Samsung Green Phone";
            result = ProductOption.Save();
            Assert.IsTrue(result);

            ProductOption.Delete();
        }
예제 #6
0
        public void ProductOption_AddNewProductOption_ReturnsTrue()
        {
            var ProductOption = new ProductOption
            {
                ProductId   = product.Id,
                Name        = "Blue Phone",
                Description = "This is a blue Samsung phone"
            };

            var result = ProductOption.Save();

            Assert.IsTrue(result);

            ProductOption.Delete();
        }
        public void UpdateOption(Guid id, ProductOption option)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var orig = new ProductOption(id)
            {
                Name        = option.Name,
                Description = option.Description
            };

            if (!orig.IsNew)
            {
                orig.Save();
            }
        }
        public IHttpActionResult CreateOption(Guid productId, ProductOption option)
        {
            var logger = Log.ForContext("productId", productId).ForContext("ProductOption", option);

            logger.Verbose(nameof(CreateOption));
            if (Product.Load(productId) == null)
            {
                return(NotFound());
            }
            option.ProductId = productId;

            if (option.Save())
            {
                return(Ok(option));
            }
            else
            {
                logger.Error($"Error in Creation something wrong with the number of elements saved {nameof(CreateOption)}");
                return(FailedToSave());
            }
        }
예제 #9
0
 public void CreateOption(Guid productId, ProductOption option)
 {
     option.ProductId = productId;
     option.Save();
 }