//Owner Takes Back His Book public ActionResult OwnerTakesBackHisBook(int?RequestId) { if (RequestId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookRequest request = dbOps.GetBookRequest(RequestId); if (request == null) { return(HttpNotFound()); } var book = dbOps.GetBook(request.BookRequested.BookId); var circulation = dbOps.GetBookLatestOnGoingCirculation(book.BookId); if (circulation == null) { return(HttpNotFound()); } var model = new ReturnBookViewModel() { Circulation = circulation, ReactionGiven = new UserReaction() { ActionGiverId = request.BookRequested.Owner.Id, ActionReceiverId = circulation.Borrower.Id, CirculationForThisReaction = circulation } }; return(View("BorrowerReturnsBook", model)); }
public async Task <IActionResult> ReturnBook(string id, int Bookid) { if (id == null) { return(NotFound()); } var user = await _userManager.FindByNameAsync(id); if (user == null) { return(NotFound()); } var book = await _context.Book.SingleOrDefaultAsync(m => m.TakenBy.UserName == id && m.BookID == Bookid); if (book == null) { return(NotFound()); } if (book.BookID != Bookid) { return(NotFound()); } ReturnBookViewModel IssueVM = new ReturnBookViewModel(); IssueVM.book = book; IssueVM.Username = user.UserName; IssueVM.BookID = book.BookID; return(View(IssueVM)); }
public ActionResult OwnerGetsBackHisBook(ReturnBookViewModel model) { dbOps.OwnerReceivedBookBack(model.Circulation); dbOps.InsertReaction(model.ReactionGiven); return(RedirectToAction("Requests", "Player")); }
public IActionResult ReturnBook(int bookId) { var book = new ReturnBookViewModel { BookId = bookId }; return(View(book)); }
public BookBorrowReturn() { InitializeComponent(); selectedBooks = new ObservableCollection <BookToShow>(); CurrentMember current = CurrentMember.getInstance(); DataContext = new ReturnBookViewModel(current.GetAccount()); UserScanerBoardViewModel.updateLedingBookList += UserScanerBoardViewModel_updateLedingBookList; }
public IActionResult Return(ReturnBookViewModel model) { if (ModelState.IsValid) { try { _bookService.AcceptBook(model.Book.Id, model.Reader.Id); return(RedirectToAction("MyBooks", "Reader", new { id = model.Reader.Id })); } catch (NotFoundException) { ModelState.AddModelError("", "Ошибка"); return(View(model)); } } return(View(model)); }
public IActionResult Return(int id) { var book = _bookRepository.GetById(id); if (book == null) { return(NotFound()); } var readers = _readerRepository.GetAll(); var vm = new ReturnBookViewModel { Book = _mapper.Map <BookViewModel>(book), Readers = _mapper.Map <IEnumerable <ReaderViewModel> >(readers) }; return(View(vm)); }
public async Task <IActionResult> ReturnBook(string id, [Bind("Username,bookID")] ReturnBookViewModel ReturnBook) { var user = await _userManager.FindByNameAsync(ReturnBook.Username); if (user == null) { return(NotFound()); } var book = await _context.Book.SingleOrDefaultAsync(m => m.BookID == ReturnBook.BookID); if (!user.TakenBooks.Contains(book)) { return(NotFound()); } book.Avaliable = true; book.TakenBy = null; _context.Book.Update(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> ReturnBook(ReturnBookViewModel vm) { try { var reviewDto = new ReviewDto { BookId = vm.BookId, UserId = User.FindFirstValue(ClaimTypes.NameIdentifier), Comment = vm.Comment, Rating = vm.Rating, }; await this.service.ReturnBookAsync(reviewDto); } catch (BookException ex) { return(View("Message", new MessageViewModel { Message = ex.Message })); } return(View("Message", new MessageViewModel { Message = "The book was returned successfully!", IsSuccess = true })); }
private void UserScanerBoardViewModel_updateLedingBookList(Account account) { DataContext = new ReturnBookViewModel(account); SelectAll.IsChecked = false; }
public IActionResult ReturnBookModel(ReturnBookViewModel model) { model.ButtonClicked = true; model.Success = _loanLogic.ReturnBook(model.BookBarcode); return(View("ReturnBook", model)); }