예제 #1
0
        // GET: Shop
        //public ActionResult Index()
        //{
        //    return View(DbInteract.GetTopProducts(6));
        //}

        public ActionResult Index(int?page)
        {
            page = page == null ? 1 : page;
            int get = (int)page;

            return(View(DbInteract.GetTopProducts(get * 6)));
        }
예제 #2
0
        private float GetTotalBill()
        {
            var   bills = db.bills.ToList();
            float total = 0;

            foreach (var bill in bills)
            {
                total += DbInteract.GetTotalOfCart(bill.cart_id);
            }
            return(total);
        }
예제 #3
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)));
 }
예제 #4
0
        // GET: Shop/Cart/:id
        public ActionResult CartInfor(int id)
        {
            if (Session["employee"] == null)
            {
                return(RedirectToAction("Login", "Employee"));
            }
            ViewBag.Carts  = waitingCarts;
            ViewBag.Colors = db.colors.ToList();
            ViewBag.Sizes  = db.sizes.ToList();

            return(View(DbInteract.GetFullDetailOfCart(id)));
        }
예제 #5
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));
        }
예제 #6
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)));
        }
예제 #7
0
        // GET: Shop/ConfirmCart/:id
        public ActionResult ConfirmCart(int id)
        {
            if (Session["employee"] == null)
            {
                RedirectToAction("Login", "Employee");
            }
            ViewBag.Carts  = waitingCarts;
            ViewBag.Colors = db.colors.ToList();
            ViewBag.Sizes  = db.sizes.ToList();

            var bill = db.bills.FirstOrDefault(m => m.cart_id.Equals(id));

            if (bill == null)
            {
                DbInteract.CreateBill(id, (Session["employee"] as employee).employee_id);

                //change cart's status
                cart cart = db.carts.FirstOrDefault(m => m.cart_id.Equals(id));
                cart.cart_status = true;
                db.SubmitChanges();
                return(RedirectToAction("CartInfor", new { id = id }));
            }
            return(RedirectToAction("CartInfor", new { id = id }));
        }
예제 #8
0
 public ActionResult Index()
 {
     ViewBag.Top5 = DbInteract.GetTopProducts(5);
     return(View(DbInteract.GetAllProducts()));
 }
예제 #9
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)));
        }
예제 #10
0
        public IEnumerable <string> Get()
        {
            DbInteract db = new DbInteract();

            return(new string[] { "value1", "value2" });
        }