// 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))); }
private float GetTotalBill() { var bills = db.bills.ToList(); float total = 0; foreach (var bill in bills) { total += DbInteract.GetTotalOfCart(bill.cart_id); } return(total); }
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))); }
// 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))); }
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)); }
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))); }
// 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 })); }
public ActionResult Index() { ViewBag.Top5 = DbInteract.GetTopProducts(5); return(View(DbInteract.GetAllProducts())); }
//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))); }
public IEnumerable <string> Get() { DbInteract db = new DbInteract(); return(new string[] { "value1", "value2" }); }