public IHttpActionResult PutLoanTable(int id, LoanTable loanTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != loanTable.LoanId) { return(BadRequest()); } loanDb.Entry(loanTable).State = EntityState.Modified; try { loanDb.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LoanTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetLoanTable(int id) { LoanTable loanTable = loanDb.LoanTables.Find(id); if (loanTable == null) { return(NotFound()); } return(Ok(loanTable)); }
public IHttpActionResult PostLoanTable(LoanTable loanTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } loanDb.LoanTables.Add(loanTable); loanDb.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = loanTable.LoanId }, loanTable)); }
public IHttpActionResult DeleteLoanTable(int id) { LoanTable loanTable = loanDb.LoanTables.Find(id); if (loanTable == null) { return(NotFound()); } loanDb.LoanTables.Remove(loanTable); loanDb.SaveChanges(); return(Ok(loanTable)); }