public IHttpActionResult Putpeopletype(int id, peopletype peopletype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != peopletype.ID) { return(BadRequest()); } db.Entry(peopletype).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!peopletypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getpeopletype(int id) { peopletype peopletype = db.peopletypes.Find(id); if (peopletype == null) { return(NotFound()); } return(Ok(peopletype)); }
public IHttpActionResult Postpeopletype(peopletype peopletype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.peopletypes.Add(peopletype); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = peopletype.ID }, peopletype)); }
public IHttpActionResult Deletepeopletype(int id) { peopletype peopletype = db.peopletypes.Find(id); if (peopletype == null) { return(NotFound()); } db.peopletypes.Remove(peopletype); db.SaveChanges(); return(Ok(peopletype)); }