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

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

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

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

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

            _context.LawChambers.Add(lawChamber);
            _context.SaveChanges();

            return(CreatedAtAction("GetLawChamber", new { id = lawChamber.Id }, lawChamber));
        }