예제 #1
0
        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());
        }
예제 #2
0
        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());
        }
예제 #3
0
        public async Task <ActionResult> Post(Producto producto)
        {
            _context.Productos.Add(producto);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetById), new { id = producto.Id }, producto));
        }
예제 #4
0
        public async Task <ActionResult> Post(DetalleOrden detalle)
        {
            _context.DetalleOrdenes.Add(detalle);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetById), new { id = detalle.Id }, detalle));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #7
0
        public async Task <T> Create(T item)
        {
            dataset.Add(item);
            await _context.SaveChangesAsync();

            return(item);
        }
예제 #8
0
        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());
        }
예제 #9
0
        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);
        }
예제 #10
0
        //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);
        }
예제 #11
0
 public async Task <int> SaveChangesAsync()
 {
     return(await _db.SaveChangesAsync());
 }