Exemplo n.º 1
0
        public async Task <IActionResult> PutHistorialConsumo(int id, HistorialConsumo historialConsumo)
        {
            if (id != historialConsumo.IdHistorial)
            {
                return(BadRequest());
            }

            _context.Entry(historialConsumo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HistorialConsumoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <ActionResult <HistorialConsumo> > PostHistorialConsumo(HistorialConsumo historialConsumo)
        {
            _context.HistorialConsumo.Add(historialConsumo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHistorialConsumo", new { id = historialConsumo.IdHistorial }, historialConsumo));
        }
Exemplo n.º 3
0
        public async Task <ActionResult <HistorialConsumo> > GetHistorialConsumo(int id)
        {
            HistorialConsumo historialConsumo = await _context.HistorialConsumo.FindAsync(id);

            if (historialConsumo == null)
            {
                return(NotFound());
            }

            return(historialConsumo);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <HistorialConsumo> > DeleteHistorialConsumo(int id)
        {
            HistorialConsumo historialConsumo = await _context.HistorialConsumo.FindAsync(id);

            if (historialConsumo == null)
            {
                return(NotFound());
            }

            _context.HistorialConsumo.Remove(historialConsumo);
            await _context.SaveChangesAsync();

            return(historialConsumo);
        }