public async Task <IHttpActionResult> PutSpeciallity(long id, Speciallity speciallity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != speciallity.speciallityID) { return(BadRequest()); } db.Entry(speciallity).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeciallityExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetSpeciallity(long id) { Speciallity speciallity = await db.Speciallities.FindAsync(id); if (speciallity == null) { return(NotFound()); } return(Ok(speciallity)); }
public async Task <IHttpActionResult> PostSpeciallity(Speciallity speciallity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Speciallities.Add(speciallity); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = speciallity.speciallityID }, speciallity)); }
public async Task <IHttpActionResult> DeleteSpeciallity(long id) { Speciallity speciallity = await db.Speciallities.FindAsync(id); if (speciallity == null) { return(NotFound()); } db.Speciallities.Remove(speciallity); await db.SaveChangesAsync(); return(Ok(speciallity)); }