public ActionResult RemoveFromCart(int id) { // Remove the item from the cart var cart = Blerja.GetCart(this.HttpContext); // Get the name of the album to display confirmation string albumName = storeDB.tbl_Shporta .Single(item => item.RecordId == id).Libri.Title; // Remove from cart int itemCount = cart.RemoveFromCart(id); // Display the confirmation message var results = new ShoppingCartRemoveViewModel { Message = Server.HtmlEncode(albumName) + " eshte larguar nga shporta juaj.", CartTotal = cart.GetTotal(), CartCount = cart.GetCount(), ItemCount = itemCount, DeletedId = id }; return(Json(results)); }
public ActionResult Adresa(FormCollection values) { var order = new Porosia(); TryUpdateModel(order); try { order.Username = User.Identity.Name; order.OrderDate = DateTime.Now; //Save Porosia storeDB.tbl_Porosia.Add(order); storeDB.SaveChanges(); //Process the order var cart = Blerja.GetCart(this.HttpContext); cart.CreateOrder(order); return(RedirectToAction("Complete", new { id = order.PorosiaId })); } catch { //Invalid - redisplay with errors return(View(order)); } }
public ActionResult Permbledhje() { var cart = Blerja.GetCart(this.HttpContext); ViewData["CartCount"] = cart.GetCount(); return(PartialView("Permbledhje")); }
private void MigrateShoppingCart(string UserName) { // Associate shopping cart items with logged-in user var cart = Blerja.GetCart(this.HttpContext); cart.MigrateCart(UserName); Session[Blerja.CartSessionKey] = UserName; }
// // GET: /Libraria/AddToCart/5 public ActionResult AddToCart(int id) { // Retrieve the album from the database var addedAlbum = storeDB.tbl_Librat .Single(album => album.LibriId == id); // Add it to the shopping cart var cart = Blerja.GetCart(this.HttpContext); cart.AddToCart(addedAlbum); // Go back to the main store page for more shopping return(RedirectToAction("Index")); }
// // GET: /Shporta/ public ActionResult Index() { var cart = Blerja.GetCart(this.HttpContext); // Set up our ViewModel var viewModel = new ShoppingCartViewModel { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; // Return the view return(View(viewModel)); }