public async Task <IActionResult> PutCliente(string id, Cliente cliente) { if (id != cliente.Id) { return(BadRequest()); } _context.Entry(cliente).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPedido(int id, Pedido pedido) { if (id != pedido.PedidoId) { return(BadRequest()); } _context.Entry(pedido).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PedidoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Post(Producto producto) { _context.Productos.Add(producto); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetById), new { id = producto.Id }, producto)); }
public async Task <ActionResult> Post(DetalleOrden detalle) { _context.DetalleOrdenes.Add(detalle); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetById), new { id = detalle.Id }, detalle)); }
public async Task <ActionResult <Restaurant> > AddRestaurant([FromBody] Restaurant restaurant) { _context.Restaurants.Add(restaurant); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetRestaurant), new { id = restaurant.Id }, restaurant)); }
public async Task <ActionResult <Plate> > AddPlate([FromBody] Plate plate) { _context.Plates.Add(plate); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetPlate), new { id = plate.Id }, plate)); }
public async Task <T> Create(T item) { dataset.Add(item); await _context.SaveChangesAsync(); return(item); }
public async Task <IActionResult> PutMesa(int id, Mesa mesa) { if (id != mesa.MesaId) { return(BadRequest()); } _context.Entry(mesa).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MesaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ResultHelper <Orden> > Create(Orden orden) { var resultado = new ResultHelper <Orden>(); try { Orden nuevaOrden = new Orden { CashierName = orden.CashierName, ClientName = orden.ClientName }; _context.Ordenes.Add(nuevaOrden); await _context.SaveChangesAsync(); resultado.Value = nuevaOrden; } catch (Exception e) { resultado.AddError(e.Message); } return(resultado); }
//Modificar ingrediente por plato public async Task <PlatoIngrediente> ModificarIngredientesPlatoAsync(int idPlato, int idCarne, int idVerdura, int idHarina, int idLacteo) { PlatoIngrediente ingredientes = GetIngredienteId(idPlato); ingredientes.CarneId = idCarne; ingredientes.VerduraId = idVerdura; ingredientes.HarinaId = idHarina; ingredientes.LacteoId = idLacteo; ingredientes.ModificadoPlato = true; ingredientes.FechaModificado = DateTime.Now; await _dbContext.SaveChangesAsync(); return(ingredientes); }
public async Task <int> SaveChangesAsync() { return(await _db.SaveChangesAsync()); }