예제 #1
0
        public ActionResult AddToCart(int id)
        {
            ProductModel product = new ProductModel(DataHelper.GetProduct(id));
            ((BasketModel)Session["Basket"]).Add(new BasketItem(product, 1, 0));

            return RedirectToAction("Index");
        }
예제 #2
0
        public ActionResult RemoveFromCart(int id, int quantity, int size)
        {
            if (!(Session["Basket"] is BasketModel))
            {
                Session["Basket"] = new BasketModel();
            }

            ProductModel product = new ProductModel(DataHelper.GetProduct(id));
            BasketModel model = ((BasketModel)Session["Basket"]);
            BasketItem item = model.Where(x => x.Product.ID == id && x.Quantity == quantity && x.Size == size).FirstOrDefault();
            if (item != null)
            {
                model.Remove(item);
            }

            return RedirectToAction("Index");
        }
예제 #3
0
        public ActionResult AddProduct(ProductModel product)
        {
            using (ClothesShopEntities entity = new ClothesShopEntities())
            {
                Product prod = new Product()
                {
                    SubCategoryID = product.SubCategoryID,
                    No = product.Number,
                    Name = product.Name,
                    NameEN = product.NameEN,
                    Description = product.Description,
                    DescriptionEN = product.DescriptionEN,
                    Price = product.Price,
                    Weight = product.Weight,
                    Special = product.Special,
                    QuantityType = (byte)product.QuantityType,
                    Quantity = product.Quantity,
                };
                entity.Products.AddObject(prod);
                entity.SaveChanges();
            }

            return RedirectToAction("Products");
        }
예제 #4
0
        public ActionResult EditProduct(ProductModel product)
        {
            ViewBag.SubCategories = DataHelper.GetAllSubcategories();

            using (ClothesShopEntities entity = new ClothesShopEntities())
            {
                Product prod = entity.Products.Where(x => x.ID == product.ID).FirstOrDefault();

                prod.SubCategoryID = product.SubCategoryID;
                prod.No = product.Number;
                prod.Name = product.Name;
                prod.NameEN = product.NameEN;
                prod.Description = product.Description;
                prod.DescriptionEN = product.DescriptionEN;
                prod.Price = product.Price;
                prod.Weight = product.Weight;
                prod.Special = product.Special;
                prod.QuantityType = (byte)product.QuantityType;
                prod.Quantity = product.Quantity;

                entity.SaveChanges();
            }

            return RedirectToAction("Products");
        }