public IHttpActionResult PutPayment(int id, Payment payment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != payment.bookID) { return(BadRequest()); } db.Entry(payment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaymentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// POST: api/bill //adding new elements public IHttpActionResult Post([FromBody] BillDTO dto) { try { var newBill = db.Bill.Add(dto.bill); db.SaveChanges(); newBill.addPaid(dto.payDones); return(Ok(newBill)); } catch (Exception e) { return(InternalServerError(e)); } }