public IHttpActionResult PostdonArticle(donArticle donArticle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.donArticles.Add(donArticle); try { db.SaveChanges(); } catch (DbUpdateException) { if (donArticleExists(donArticle.IDarticleDon)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = donArticle.IDarticleDon }, donArticle)); }
public IHttpActionResult PutdonArticle(int id, donArticle donArticle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != donArticle.IDarticleDon) { return(BadRequest()); } db.Entry(donArticle).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!donArticleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetdonArticle(int id) { donArticle donArticle = db.donArticles.Find(id); if (donArticle == null) { return(NotFound()); } return(Ok(donArticle)); }
public IHttpActionResult DeletedonArticle(int id) { donArticle donArticle = db.donArticles.Find(id); if (donArticle == null) { return(NotFound()); } db.donArticles.Remove(donArticle); db.SaveChanges(); return(Ok(donArticle)); }