예제 #1
0
        public IActionResult OnPost(int?productId)      // Make sure productId gets in here OK
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (Attribute.Id > 0)
            {
                Attribute = attributeData.Update(Attribute);
            }
            else
            {
                attributeData.Add(Attribute);
            }

            attributeData.Commit();
            TempData["Message"] = "Attribute has been saved!";

            if (productId.HasValue)
            {
                ProductAttributes             = new ProductAttributes();
                ProductAttributes.ProductId   = productId.Value;
                ProductAttributes.AttributeId = Attribute.Id;
                productAttributesData.Add(ProductAttributes);
                productAttributesData.Commit();
            }



            return(RedirectToPage("./AttributeDetails", new { attributeId = Attribute.Id }));
        }
예제 #2
0
        public IActionResult OnPost(int attributeId)
        {
            var i = 0;

            ProductAttributesData = productAttributesData;
            foreach (var boolean in IsChecked)
            {
                if (boolean)
                {
                    var pa = new ProductAttributes();
                    pa.AttributeId = attributeId;
                    pa.ProductId   = productData.GetProductsByName("").ToList()[i].Id;
                    ProductAttributesData.Add(pa);
                    productAttributesData.Commit();
                }
                i++;
            }
            return(RedirectToPage("./List"));
        }