public ActionResult GuardarAlta([FromBody] DTOCarritoItem nuevoItem) { if (!ModelState.IsValid) { return(View("Error", new Error() { Message = "Error in data" })); } if (nuevoItem.ItemInventario != null) { if (nuevoItem.ItemInventario.Catalogo == null) { var auxCatalogoItem = RepoCatalogo.ObtenerXID(nuevoItem.ItemInventario.CatalogoId.Value); nuevoItem.ItemInventario.Catalogo = auxCatalogoItem; } nuevoItem.Calcular(); var Inv = new InventarioBLL(); //nuevoItem.ItemInventario=Inv.ObtenerXID(nuevoItem.ItemInventario.Catalogo.Id); saveItemInCarrito(nuevoItem); return(View("Carrito", Carrito.getCarrito())); } return(View("Carrito", Carrito.getCarrito())); }
public void quitarIteminCarrito(DTOCarritoItem nuevoItem) { var auxCarrito = Carrito.getCarrito(); auxCarrito.Remover(nuevoItem.ID); this.saveCarrito(auxCarrito); }
private void saveItemInCarrito(DTOCarritoItem nuevoItem) { var auxCarrito = Carrito.getCarrito(); auxCarrito.Agregar(nuevoItem); Carrito.setCarrito(auxCarrito); }
public void AgregarItem(DTOCarritoItem unItem) { var InventarioRepo = new InventarioBLL(); unItem.ItemInventario = InventarioRepo.ObtenerXID(unItem.ItemInventario.Id); unItem.SessionID = Session.Id; Compra.Items.Add(unItem); Guardar(); }
public void QuitarItem(DTOCarritoItem unItem) { var auxItem = Compra.Items.Where(x => x.ItemInventario.Id == unItem.ItemInventario.Id).FirstOrDefault(); if (auxItem != null) { Compra.Items.Remove(auxItem); Guardar(); } }
public ActionResult PrepararAgregarItem(long ID) { //Recuperar item del Inventario, mostrar la página de agregar al carrito //con los campos autocompletados var InventarioRepo = new InventarioBLL(); var newItem = new DTOCarritoItem(); newItem.InventarioID = ID; newItem.ItemInventario = InventarioRepo.ObtenerXID(ID); newItem.SessionID = HttpContext.Session.Id; //newItem.Calcular(); ViewBag.ModoOper = "NEW"; return(View("CarritoItem", newItem)); }
public ActionResult ModificarItem([FromBody] DTOCarritoItem itemExistente) { if (!ModelState.IsValid) { return(View("Error", new Error() { Message = "Error in data" })); } var auxCarrito = Carrito.getCarrito(); var oldItem = auxCarrito.Items.Where(x => x.InventarioID == itemExistente.InventarioID).FirstOrDefault(); auxCarrito.Modificar(oldItem.ID, itemExistente); Carrito.setCarrito(auxCarrito); return(View("Carrito", auxCarrito)); }