Exemplo n.º 1
0
        public async Task <IActionResult> PutConsumoHist([FromRoute] int id, [FromBody] ConsumoHist consumoHist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != consumoHist.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostConsumoHist([FromBody] ConsumoHist consumoHist)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ConsumosHists.Add(consumoHist);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetConsumoHist", new { id = consumoHist.Id }, consumoHist));
        }