public ActionResult add(tShoppingCar item) { int prodID = Convert.ToInt32(item.fProduct); tProject t = db.tProject.FirstOrDefault(p => p.fid == prodID); if (t != null) { item.fDate = DateTime.Now.ToString("yyyyMMddHHmmss"); item.fCustomer = "cthulu"; item.fPrice = t.fprice; db.tShoppingCar.Add(item); db.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult addsession(tShoppingCar item) { int prodID = Convert.ToInt32(item.fProduct); tProject t = db.tProject.FirstOrDefault(p => p.fid == prodID); if (t != null) { List <CShoppingCartItem> list = (List <CShoppingCartItem>)Session[CDictionary.SK_PURCHASED_IN_SHOPPINGCART]; if (list == null) { list = new List <CShoppingCartItem>(); Session[CDictionary.SK_PURCHASED_IN_SHOPPINGCART] = list; } CShoppingCartItem x = new CShoppingCartItem(); x.price = Convert.ToDouble(t.fprice); x.productID = t.fid; x.productname = t.fname; x.count = (int)item.fCount; list.Add(x); } return(RedirectToAction("List")); }
public ActionResult ShoppingCar(string fPid) { string uid = User.Identity.Name; var ShoppingCar = db.tShoppingCar.Where(m => m.fUId == uid && m.fPId == fPid).FirstOrDefault(); if (ShoppingCar != null) { ShoppingCar.fQty += 1; } else { var product = db.tProduct.Where(m => m.fPId == fPid).FirstOrDefault(); tShoppingCar newCar = new tShoppingCar(); newCar.fUId = uid; newCar.fPId = fPid; newCar.fPName = product.fPName; newCar.fPrice = product.fPrice; newCar.fQty = 1; db.tShoppingCar.Add(newCar); } db.SaveChanges(); return(RedirectToAction("ShoppingCarList")); }