public async Task <IActionResult> PutRental([FromRoute] int id, [FromBody] Rental rental) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rental.Id) { return(BadRequest()); } context.Entry(rental).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentalExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustomer(int id, Customer customer) { if (id != customer.CustomerId) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IHttpActionResult> PutRentState(int id, RentState rentState) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rentState.RentStateId) { return(BadRequest()); } db.Entry(rentState).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentStateExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutBike(int id, Bike bike) { if (id != bike.BikeId) { return(BadRequest()); } _context.Entry(bike).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok()); }