public async Task <IActionResult> UpdateRentedBookHistory(int rentedBookHistoryId, [FromBody] BorrowedBookHistoryDTO rentedBookHistory) { if (rentedBookHistoryId != rentedBookHistory.BorrowedBookHistoryId) { return(BadRequest()); } _wrapper.BorrowedBookHistoryRepository.UpdateRentedBookHistory(_mapper.Map <BorrowedBookHistory>(rentedBookHistory)); try { await _wrapper.SaveAsync(); } catch (DbUpdateConcurrencyException e) { if (!await RentedBookHistoryExists(rentedBookHistoryId)) { return(NotFound()); } else { return(BadRequest(e.Message)); } } return(Ok()); }
public async Task <ActionResult <BorrowedBookHistoryDTO> > CreateRentedBookHistory([FromBody] BorrowedBookHistoryDTO rentedBookHistory) { _wrapper.BorrowedBookHistoryRepository.CreateRentedBookHistory(_mapper.Map <BorrowedBookHistory>(rentedBookHistory)); try { await _wrapper.SaveAsync(); } catch (DbUpdateException e) { return(BadRequest(e.Message)); } return(CreatedAtAction(nameof(CreateRentedBookHistory), new { id = rentedBookHistory.BorrowedBookHistoryId }, rentedBookHistory)); }