public async Task <IActionResult> PutMediapost([FromRoute] int id, [FromBody] Mediapost mediapost) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mediapost.IdPost) { return(BadRequest()); } _context.Entry(mediapost).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MediapostExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostMediapost([FromBody] Mediapost mediapost) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Mediapost.Add(mediapost); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMediapost", new { id = mediapost.IdPost }, mediapost)); }