/// <summary> /// Funkcja do usuwania trwającego wypożyczenia o podanym ID /// </summary> /// <param name="id"></param> /// <returns></returns> // DELETE: api/Loans/5 public async Task <IHttpActionResult> DeleteLoan(int id) { Loan loan = await _loanRepository.GetByIdAsync(id); if (loan == null) { return(NotFound()); } var result = await _loanRepository.DeleteAsync(loan); if (!result) { return(InternalServerError()); } return(Ok(loan)); }
public async Task <ActionResult> DeleteConfirmed(int id) { Loan loan = await _loanRepository.GetByIdAsync(id); if (loan == null) { return(HttpNotFound()); } var book = await _bookRepository.GetByIdAsync(loan.BookID); await _loanRepository.DeleteAsync(loan); book.Amount++; await _bookRepository.SaveAsync(book); return(RedirectToAction("Index")); }