public IHttpActionResult PutTbNew(int id, TbNew tbNew) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbNew.id) { return(BadRequest()); } db.Entry(tbNew).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TbNewExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTbNew(int id) { TbNew tbNew = db.TbNews.Find(id); if (tbNew == null) { return(NotFound()); } return(Ok(tbNew)); }
public IHttpActionResult PostTbNew(TbNew tbNew) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TbNews.Add(tbNew); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tbNew.id }, tbNew)); }
public IHttpActionResult DeleteTbNew(int id) { TbNew tbNew = db.TbNews.Find(id); if (tbNew == null) { return(NotFound()); } db.TbNews.Remove(tbNew); db.SaveChanges(); return(Ok(tbNew)); }