public async Task <IActionResult> PutComment([FromRoute] int id, [FromBody] Comment comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != comment.ID) { return(BadRequest()); } _context.Entry(comment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostForum([FromBody] Forum forum) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Forums.Add(forum); await _context.SaveChangesAsync(); return(CreatedAtAction("GetForum", new { id = forum.ID }, forum)); }
public async Task <IActionResult> PostOpinion([FromBody] Opinion opinion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Opinions.Add(opinion); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOpinion", new { id = opinion.ID }, opinion)); }
public async Task <IActionResult> PostMark([FromBody] Mark mark) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Marks.Add(mark); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMark", new { id = mark.ID }, mark)); }
public async Task <IActionResult> PostCity([FromBody] City city) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Cities.Add(city); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCity", new { id = city.ID }, city)); }