public IHttpActionResult Put(int id, ELathe eLathe) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eLathe.lathe_id) { return(BadRequest()); } db.Entry(eLathe).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ELatheExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Get(int id) { ELathe eLathe = db.ELathes.Find(id); if (eLathe == null) { return(NotFound()); } return(Ok(eLathe)); }
public IHttpActionResult Post(ELathe eLathe) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ELathes.Add(eLathe); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = eLathe.lathe_id }, eLathe)); }
public IHttpActionResult Delete(int id) { ELathe eLathe = db.ELathes.Find(id); if (eLathe == null) { return(NotFound()); } db.ELathes.Remove(eLathe); db.SaveChanges(); return(Ok(eLathe)); }