public async Task <IActionResult> ReserveBook(BookTitleViewModel vm) { var reserveDto = new BaseTitleDto { Title = vm.Title, UserId = User.FindFirstValue(ClaimTypes.NameIdentifier) }; var result = await this.service.ReserveBookAsync(reserveDto); if (!result) { return(View("Message", new MessageViewModel { Message = "Book was not found!" })); } return(View("Message", new MessageViewModel { Message = $"The book {vm.Title} was reserved successfully!", IsSuccess = true })); }
public async Task <IActionResult> LendBook(BookTitleViewModel vm) { try { var lendDto = new BaseTitleDto { Title = vm.Title, UserId = User.FindFirstValue(ClaimTypes.NameIdentifier) }; await this.service.LendBookAsync(lendDto); } catch (BookException ex) { return(View("Message", new MessageViewModel { Message = ex.Message })); } return(View("Message", new MessageViewModel { Message = $"The book {vm.Title} was lended successfully!", IsSuccess = true })); }