public async Task <IActionResult> PutPost([FromRoute] int id, [FromBody] Post post) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != post.Id) { return(BadRequest()); } _context.Entry(post).State = EntityState.Modified; try { post.UpdateOn = DateTime.Now; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTag([FromRoute] int id, [FromBody] Tag tag) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tag.Id) { return(BadRequest()); } _context.Entry(tag).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }