Exemplo n.º 1
0
        public ActionResult DeleteProduct(int ProductID)
        {
            CandleShopEntities ORM     = new CandleShopEntities();
            Product            product = ORM.Products.Find(ProductID);

            ORM.Products.Remove(product);
            ORM.SaveChanges();

            return(RedirectToAction("EditDeleteProductList"));
        }
Exemplo n.º 2
0
        public ActionResult SaveNewProduct(Product newProduct)
        {
            CandleShopEntities ORM      = new CandleShopEntities();
            List <Product>     products = ORM.Products.Where(p => p.Name.Equals(newProduct.Name)).ToList();

            if (products.Count == 0)
            {
                ORM.Products.Add(newProduct);
                ORM.SaveChanges();
            }

            return(RedirectToAction("EditDeleteProductList"));
        }
Exemplo n.º 3
0
        public ActionResult SaveProductChanges(Product updatedProduct)
        {
            CandleShopEntities ORM        = new CandleShopEntities();
            Product            oldProduct = ORM.Products.Find(updatedProduct.ProductID);

            oldProduct.Name            = updatedProduct.Name;
            oldProduct.Price           = updatedProduct.Price;
            oldProduct.QuantityInStock = updatedProduct.QuantityInStock;

            ORM.Entry(oldProduct).State = EntityState.Modified;
            ORM.SaveChanges();

            return(RedirectToAction("EditDeleteProductList"));
        }
        public ActionResult AddProduct(Product selectedProduct)
        {
            CandleShopEntities ORM = new CandleShopEntities();

            Product productToAdd = ORM.Products.Find(selectedProduct.ProductID);

            productToAdd.UserName = User.Identity.Name;


            ORM.Products.Add(productToAdd);
            ORM.SaveChanges();

            ViewBag.Candle = productToAdd.Name;

            return(View());
        }
        public ActionResult Welcome(User user)
        {
            CandleShopEntities ORM        = new CandleShopEntities();
            List <User>        userEmails = ORM.Users.Where(u => u.Email.Equals(user.Email)).ToList();

            if (userEmails.Count == 0)
            {
                ORM.Users.Add(user);
                ORM.SaveChanges();
                ViewBag.DuplicateEmail = false;
            }
            else
            {
                ViewBag.DuplicateEmail = true;
            }

            return(View(user));
        }