public async Task<IHttpActionResult> PutArticle(int id, Article article) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != article.Id) { return BadRequest(); } _uow.ArticleRepository.Insert(article); try { await _uow.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (_uow.ArticleRepository.GetById(id) == null) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.Created); }
public async Task<IHttpActionResult> PostArticle(Article article) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _uow.ArticleRepository.Insert(article); await _uow.SaveChangesAsync(); return CreatedAtRoute("GetArticleById", new { id = article.Id }, article); }