public IHttpActionResult PutTyer(int id, Tyer tyer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tyer.TyerId) { return(BadRequest()); } db.Entry(tyer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TyerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTyer(int id) { Tyer tyer = db.Tyers.Find(id); if (tyer == null) { return(NotFound()); } return(Ok(tyer)); }
public IHttpActionResult PostTyer(Tyer tyer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Tyers.Add(tyer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tyer.TyerId }, tyer)); }
public IHttpActionResult DeleteTyer(int id) { Tyer tyer = db.Tyers.Find(id); if (tyer == null) { return(NotFound()); } db.Tyers.Remove(tyer); db.SaveChanges(); return(Ok(tyer)); }