// GET: Product public ActionResult Index() { //load cart var cus = Session["cus"] as Girft_shop.ViewModel.CartVM; ViewBag.countCart = cus.count; ViewBag.totalCart = cus.amount; ViewData["cart"] = cus._cart; //end load var id = Request.Params["id"]; if (id == null) { return(RedirectToAction("Index", "Home")); } var pro = new girftEntities().products.ToList().Where(x => x.id.ToString() == id).FirstOrDefault(); ViewBag.name = pro.name; ViewBag.description = pro.description; ViewBag.price = pro.price; ViewBag.img = pro.img; ViewBag.id = pro.id; ViewBag.dis = pro.price * 0.9; return(View()); }
public ActionResult Login() { String user = Request.Params["username"]; String pass = Request.Params["pass"]; var table = new girftEntities().accounts; var userModel = table.Where(x => x.userID == user).FirstOrDefault(); var check = table.Where(x => x.userID == user); if (userModel != null) { var password = userModel.password.Trim(); using (MD5 md5Hash = MD5.Create()) { String md5Pass = GetMd5Hash(md5Hash, pass); if (md5Pass == password) { Session["user"] = user; return(RedirectToAction("Orders")); } else { return(RedirectToAction("Index", new { message = "login fail" })); } } } return(RedirectToAction("Index", new { message = "login fail" })); }
public ActionResult ProductCate() { if (Session["user"] == null) { return(RedirectToAction("Index", "Admin")); } IList <product> LsProducts = new girftEntities().products.ToList(); ViewData["products"] = LsProducts; return(View()); }
public List <SubProducts> Teddy(String condition) { List <product> teddyPro = new List <product>(); var model = new girftEntities(); // get data teddy if (condition != null) { teddyPro = model.products.Where(x => x.type.Contains(condition)).ToList(); } else { teddyPro = model.products.ToList(); } List <SubProducts> subTable = new List <SubProducts>(); foreach (var item in teddyPro) { var tmp = (double)item.price * 0.9; String link = "/product?id=" + item.id.ToString(); subTable.Add( new SubProducts() { id = item.id, name = item.name, img = item.img, price = item.price, discount = tmp, type = item.type, link = link } ); } return(subTable); }