Ejemplo n.º 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 }));
        }
Ejemplo n.º 2
0
        public IActionResult OnPost(int productId)
        {
            var product          = productData.Delete(productId);
            var productAttribute = productAttributesData.DeleteProduct(productId);

            productData.Commit();
            productAttributesData.Commit();

            if (product == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            TempData["Message"] = $"{product.Manufacturer} {product.Model} deleted";
            return(RedirectToPage("./List"));
        }
Ejemplo n.º 3
0
        public IActionResult OnPost(int attributeId)
        {
            var Attribute = attributeData.Delete(attributeId);
            var removedId = productAttributesData.DeleteAttribute(attributeId);

            attributeData.Commit();
            productAttributesData.Commit();

            if (Attribute == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = "Attribute Deleted!";
            return(RedirectToPage("./List"));
        }
Ejemplo n.º 4
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"));
        }