public IHttpActionResult Post(Tbl_Cart cart) { //adminLoginRepository.Insert(Admin); cartrepository.Insert(cart); return(Created("api/carts/" + cart.CartId, cart)); }
/// <summary> /// Remove Cart Item /// </summary> /// <param name="productId"></param> /// <returns></returns> public ActionResult RemoveCartItem(int productId) { Tbl_Cart c = _unitOfWork.GetRepositoryInstance <Tbl_Cart>().GetFirstOrDefaultByParameter(i => i.ProductId == productId && i.MemberId == memberId && i.CartStatusId == 1); c.CartStatusId = 2; c.UpdatedOn = DateTime.Now; _unitOfWork.GetRepositoryInstance <Tbl_Cart>().Update(c); _unitOfWork.SaveChanges(); return(RedirectToAction("MyCart")); }
/// <summary> /// Add Product To Cart /// </summary> /// <param name="productId"></param> /// <returns></returns> public ActionResult AddProductToCart(int productId) { Tbl_Cart c = new Tbl_Cart(); c.AddedOn = DateTime.Now; c.CartStatusId = 1; c.MemberId = memberId; c.ProductId = productId; c.UpdatedOn = DateTime.Now; _unitOfWork.GetRepositoryInstance <Tbl_Cart>().Add(c); _unitOfWork.SaveChanges(); TempData["ProductAddedToCart"] = "Product added to cart successfully"; return(RedirectToAction("Index", "Search")); }
public int AddProductToCart(int itemId) { var memberid = User.FindFirstValue(ClaimTypes.Sid); Tbl_Cart tbl_Cart = new Tbl_Cart(); tbl_Cart.AddedOn = DateTime.Now; tbl_Cart.CartStatusId = 1; tbl_Cart.MemberId = Convert.ToInt32(memberid); tbl_Cart.ProductId = itemId; tbl_Cart.UpdatedOn = DateTime.Now; Cart_repository.Insert(tbl_Cart); Cart_repository.Save(); return(1); }
public ActionResult RemoveFromCart(int productId) { if (Session["UserId"] != null) { var UserId = (int)Session["UserId"]; Tbl_Cart cart = _unitOfWork.GetRepositoryInstance <Tbl_Cart>().GetFirstOrDefaultByParameter(a => a.MemberId == UserId && a.ProductId == productId && a.OrderStatues == false && a.Confirmed == false); _unitOfWork.GetRepositoryInstance <Tbl_Cart>().Remove(cart); } else { return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Index")); }
public IActionResult AddProductToCart1(int itemId) { var memberid = User.FindFirstValue(ClaimTypes.Sid); Tbl_Cart tbl_Cart = new Tbl_Cart(); tbl_Cart.AddedOn = DateTime.Now; tbl_Cart.CartStatusId = 1; tbl_Cart.MemberId = Convert.ToInt32(memberid); tbl_Cart.ProductId = itemId; tbl_Cart.UpdatedOn = DateTime.Now; Cart_repository.Insert(tbl_Cart); Cart_repository.Save(); //TempData["ProductAddedToCart"] = "Product added to cart successfully"; return(RedirectToAction("Cart")); }
// GET: Shopping /// <summary> /// Add Product To Cart /// </summary> /// <param name="productId"></param> /// <returns></returns> public ActionResult AddProductToCart(HomeViewModel Model, FormCollection collection) { var userid = PublicHelper.UserId; if (userid == null || userid == "") { TempData["Login"] = "******"; TempData["Status"] = false; return(RedirectToAction("Login", "Account")); } var productId = Convert.ToInt32(collection["userid"]); var cartid = Convert.ToInt32(userid); var getproduct = _context.tbl_Product.Where(p => p.ProductId == productId).SingleOrDefault(); Tbl_Cart c = new Tbl_Cart(); Notification n = new Notification(); c.AddedOn = DateTime.Now; c.CartStatusId = 1; c.UserId = Convert.ToInt32(userid); c.ProductId = productId; c.Size = collection["selectsize"]; c.Color = collection["selectcolor"]; c.UpdatedOn = DateTime.Now; _context.Tbl_Cart.Add(c); _context.SaveChanges(); n.Ischecked = true; n.createdBY = Convert.ToInt32(userid); n.userID = Convert.ToInt32(userid); n.createdON = DateTime.Now; n.productID = productId; n.categoryID = getproduct.CategoryID; n.BrandID = getproduct.BrandID; _context.Notifications.Add(n); _context.SaveChanges(); TempData["ProductAddedToCart"] = "Product added to cart successfully"; TempData["Status"] = true; return(RedirectToAction("Index", "Home", new { prodId = productId })); }
/// <summary> /// //////////////////////////////////////////////// /// </summary> /// <param name="productId"></param> /// <param name="url"></param> /// <returns></returns> public ActionResult AddToCart(int productId, string url) { if (Session["UserId"] != null) { var UserId = (int)Session["UserId"]; var cart = _unitOfWork.GetRepositoryInstance <Tbl_Cart>().GetFirstOrDefaultByParameter(a => a.MemberId == UserId && a.ProductId == productId && a.OrderStatues == false && a.Confirmed == false); if (cart == null || cart.OrderStatues == true) { cart = new Tbl_Cart() { ProductId = productId, Quantity = 1, MemberId = UserId, Confirmed = false, OrderStatues = false } ; _unitOfWork.GetRepositoryInstance <Tbl_Cart>().Add(cart); } else { int prvQty = (int)cart.Quantity; cart.Quantity = prvQty + 1; _unitOfWork.GetRepositoryInstance <Tbl_Cart>().Update(cart); } } else { return(RedirectToAction("Login", "Account")); } return(Redirect(url)); }
public IHttpActionResult Put([FromUri] int id, [FromBody] Tbl_Cart cart) { cart.CartId = id; cartrepository.Update(cart); return(Ok(cart)); }