Esempio n. 1
0
 public ActionResult ProductDetail(int id)
 {
     if (Session["employee"] == null)
     {
         return(RedirectToAction("Login", "Employee"));
     }
     if ((Session["employee"] as employee).employee_role < 1)
     {
         return(RedirectToAction("Login"));
     }
     return(View(DbInteract.GetProduct(id)));
 }
Esempio n. 2
0
        public ActionResult AddToCart(FormCollection cartItem)
        {
            List <CartItem> carts = Session["cart"] == null ? (new List <CartItem>()) : (List <CartItem>)Session["cart"];
            CartItem        item  = carts.Find(m => m.Product.Id == int.Parse(cartItem["IdProduct"]));

            if (item != null)
            {
                item.Quantity = int.Parse(cartItem["quantity"]);
            }
            else
            {
                carts.Add(new CartItem(
                              DbInteract.GetProduct(int.Parse(cartItem["IdProduct"])),
                              int.Parse(cartItem["quantity"]),
                              int.Parse(cartItem["color"]),
                              int.Parse(cartItem["size"])));
                Session["cart"] = carts;
            }
            return(RedirectToAction("Cart", "Shop", carts));
        }
Esempio n. 3
0
        public ActionResult EditProduct(int id)
        {
            if (Session["employee"] == null)
            {
                return(RedirectToAction("Login", "Employee"));
            }
            if ((Session["employee"] as employee).employee_role < 1)
            {
                return(RedirectToAction("Login"));
            }
            ViewBag.Color = db.colors.ToList();
            Product product = DbInteract.GetProduct(id);

            return(View(new ProductViewModels(product.Id,
                                              product.Quantum,
                                              product.Price,
                                              product.Name,
                                              product.Describle,
                                              product.Tag,
                                              product.Colors.Id)));
        }
Esempio n. 4
0
        //public Product GetProduct(int id)
        //{
        //    var productFromDb = (from a in db.products
        //                         join b in db.product_details
        //                          on a.product_id equals b.product_id
        //                         join c in db.product_imgs
        //                          on a.product_id equals c.product_id
        //                         join d in db.colors
        //                          on c.color_id equals d.color_id
        //                         where a.product_id == id
        //                         select new
        //                         {
        //                             a.product_id,
        //                             a.product_quantum,
        //                             a.product_price,
        //                             b.product_decrible,
        //                             b.product_tag,
        //                             c.color_id,
        //                             d.color_name,
        //                             d.color_hex,
        //                             b.product_name,
        //                             c.product_img_path
        //                         }).ToList();
        //    Product product = new Product();

        //    product.Id = productFromDb[0].product_id;
        //    product.Price = (float)productFromDb[0].product_price;
        //    product.Quantum = (int)productFromDb[0].product_quantum;
        //    product.Tag = productFromDb[0].product_tag;
        //    product.Name = productFromDb[0].product_name;
        //    product.Describle = productFromDb[0].product_decrible;

        //    foreach (var i in productFromDb)
        //    {
        //        product.ImagePaths = new ProductImg(i.product_id, i.product_img_path, i.color_id);
        //        product.Colors = new Color(i.color_id, i.color_name, i.color_hex);
        //    }
        //    return product;
        //}

        public ActionResult Product(int id)
        {
            ViewBag.Color = db.colors.ToList();
            ViewBag.Size  = db.sizes.ToList();
            return(View(DbInteract.GetProduct(id)));
        }