public async Task <IHttpActionResult> PutSavingsDetails(int id, SavingsDetails savingsDetails) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != savingsDetails.ID) { return(BadRequest()); } db.Entry(savingsDetails).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SavingsDetailsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetSavingsDetails(int id) { SavingsDetails savingsDetails = await db.SavingsDetails.FindAsync(id); if (savingsDetails == null) { return(NotFound()); } return(Ok(savingsDetails)); }
public async Task <IHttpActionResult> PostSavingsDetails(SavingsDetails savingsDetails) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SavingsDetails.Add(savingsDetails); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = savingsDetails.ID }, savingsDetails)); }
public async Task <IHttpActionResult> DeleteSavingsDetails(int id) { SavingsDetails savingsDetails = await db.SavingsDetails.FindAsync(id); if (savingsDetails == null) { return(NotFound()); } db.SavingsDetails.Remove(savingsDetails); await db.SaveChangesAsync(); return(Ok(savingsDetails)); }