public async Task<IHttpActionResult> Post(Post post) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _repository.Insert(post); await _repository.Save(); return Ok(post); }
public async Task<IHttpActionResult> Put(int id, Post post) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != post.Id) { return BadRequest(); } _repository.Update(post); await _repository.Save(); return Ok(post); }