public ActionResult RemoveFromCart(int id) { // Remove the item from the cart var cart = CarritodeCompras.GetCart(this.HttpContext); //Get the name of the album to display confirmation string albumName = storeDB.Carritos .Single(item => item.ArticuloId == id).Ejemplar.Titulo; // Remove from cart int itemCount = cart.RemoveFromCart(id); // Display the confirmation message var results = new ShoppingCartRemoveViewModel { Message = Server.HtmlEncode(albumName) + " a sido removido del carrito de compras.", CartTotal = cart.GetTotal(), CartCount = cart.GetCount(), ItemCount = itemCount, DeleteId = id }; return(Json(results)); }
public ActionResult CartSummary() { var carrito = CarritodeCompras.GetCart(this.HttpContext); ViewData["CartCount"] = carrito.GetCount(); return(PartialView("CartSummary")); }
public ActionResult DescontarToCart(int id, int cant, int idCart) { var quitarProducto = storeDB.PRODUCTO .Single(producto => producto.COD_PRO == id); var carrito = CarritodeCompras.GetCart(this.HttpContext); carrito.DescontarToCart(quitarProducto, cant, idCart); return(RedirectToAction("Index")); }
public ActionResult AddToCart(int id, int cant) { Console.WriteLine("codigo del producto a agregar", id); // Retrieve the album from the database var addedProducto = storeDB.PRODUCTO .Single(producto => producto.COD_PRO == id); // Add it to the shopping cart var carrito = CarritodeCompras.GetCart(this.HttpContext); carrito.AddToCart(addedProducto, cant); // Go back to the main store page for more shopping return(RedirectToAction("Index")); }
public ActionResult Index() { var carrito = CarritodeCompras.GetCart(this.HttpContext); // Set up our ViewModel var viewModel = new VistaModelCarritoCompras { CarritoItems = carrito.GetCartItems(), CarritoTotal = carrito.GetTotal() }; // Return the view return(View(viewModel)); }
public ActionResult Pago(PEDIDO pedido) { db.PEDIDO.Add(pedido); db.SaveChanges(); //Process the order var cart = CarritodeCompras.GetCart(this.HttpContext); string cartDetalle = cart.tablaDetalle(); PEDIDO ped = cart.CreateOrder(pedido); db.Entry(ped).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Completo", new { idPed = pedido.idpedido })); }
// // GET: /Tienda/AddToCart/5 public ActionResult AddToCart(int id) { // Retrieve the album from the database var addedEjemplar = storeDB.Ejemplares .Single(ejemplar => ejemplar.EjemplarId == id); // Add it to the shopping cart var cart = CarritodeCompras.GetCart(this.HttpContext); cart.AddToCart(addedEjemplar); // Go back to the main store page for more shopping return(RedirectToAction("Index")); }
// // GET: /CarritodeCompras/ public ActionResult Index() { var cart = CarritodeCompras.GetCart(this.HttpContext); // Set up our ViewModel var viewModel = new ShoppingCartViewModel { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; // Return the view return(View(viewModel)); }
public ActionResult EliminarDelCarrito(int id) { // Remove the item from the cart var carrito = CarritodeCompras.GetCart(this.HttpContext); // Get the name of the album to display confirmation string nombreProducto = storeDB.CART .Single(item => item.COD_CART == id).PRODUCTO.DES_PRO; // Remove from cart int itemCount = carrito.EliminarDelCarrito(id); // Display the confirmation message var results = new VistaModelRemoverCarritoCompras { Mensaje = Server.HtmlEncode(nombreProducto) + " ha sido removido de su carrito de compras.", TotalCarrito = carrito.GetTotal(), CartCount = carrito.GetCount(), ItemCount = itemCount, DeleteId = id }; return(Json(results)); }
public ActionResult AddressAndPayment(FormCollection values) { var order = new Orden(); TryUpdateModel(order); try { if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == false) { return(View(order)); } else { order.NombreUsuario = User.Identity.Name; order.FechaOrden = DateTime.Now; //Save Order storeDB.Ordenes.Add(order); storeDB.SaveChanges(); //Process the order var cart = CarritodeCompras.GetCart(this.HttpContext); cart.CreateOrder(order); return(RedirectToAction("Complete", new { id = order.OrdenId })); } } catch { //Invalid - redisplay with errors return(View(order)); } }