public IActionResult Update(Rental rentals) { var result = _rentalsService.Update(rentals); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,StartDate,EndDate,CustomerId,BookId")] Rental rental) { if (id != rental.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _rentalsService.Update(rental); } catch (DbUpdateConcurrencyException) { if (!_rentalsService.RentalExists(rental.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var books = await _booksService.GetAllAsync(); var customers = await _customersService.GetAllAsync(); ViewData["BookId"] = new SelectList(books, "Id", "Title", rental.BookId); ViewData["CustomerId"] = new SelectList(customers, "Id", "FullName", rental.CustomerId); return(View(rental)); }