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

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

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

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

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

            _context.PutUps.Add(putUp);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPutUp", new { id = putUp.Id }, putUp));
        }