public async Task <IHttpActionResult> PutAppreciationReason(int id, AppreciationReason appreciationReason) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != appreciationReason.AppreciationReasonId) { return(BadRequest()); } db.Entry(appreciationReason).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppreciationReasonExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAppreciationReason(int id) { AppreciationReason appreciationReason = await db.AppreciationReasons.FindAsync(id); if (appreciationReason == null) { return(NotFound()); } return(Ok(appreciationReason)); }
public async Task <IHttpActionResult> PostAppreciationReason(AppreciationReason appreciationReason) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AppreciationReasons.Add(appreciationReason); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = appreciationReason.AppreciationReasonId }, appreciationReason)); }
public async Task <IHttpActionResult> DeleteAppreciationReason(int id) { AppreciationReason appreciationReason = await db.AppreciationReasons.FindAsync(id); if (appreciationReason == null) { return(NotFound()); } db.AppreciationReasons.Remove(appreciationReason); await db.SaveChangesAsync(); return(Ok(appreciationReason)); }