示例#1
0
        public async Task <IActionResult> PutElementoPermitido([FromRoute] int id, [FromBody] ElementoPermitido elementoPermitido)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> PostElementoPermitido([FromBody] ElementoPermitido elementoPermitido)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ElementoPermitido.Add(elementoPermitido);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetElementoPermitido", new { id = elementoPermitido.Id }, elementoPermitido));
        }