public async Task <ActionResult> ReturnBook(BookTransactionDto req)
        {
            if (!await _memberService.HasPendingSignOut(req.MemberId, req.LibraryId, req.BookId))
            {
                ModelState.AddModelError(string.Empty, Messages.SignOutDifferentLibraryError);
                return(View(await BuildReturnBookVM(req.LibraryId)));
            }

            await _memberService.ReturnBook(req.BookId, req.LibraryId, req.MemberId);

            ViewBag.SuccessMessage = Messages.ReturnSuccessfully;
            return(View(await BuildReturnBookVM(req.LibraryId)));
        }
Beispiel #2
0
        public async Task <int> CreateTransaction(BookTransactionDto modelDto)
        {
            try
            {
                var entity = mapper.Map <BookTransactionDto, BookTransaction>(modelDto);
                await transactionService.Create(entity);

                return(1);
            }
            catch
            {
                return(0);
            }
        }
        public async Task <ActionResult> SignOutBook(BookTransactionDto req)
        {
            var count = await _memberService.GetMemberSignOutCount(req.MemberId, req.LibraryId);

            if (count >= Consts.MAX_BOOKS_SIGNOUT_PER_LIBRARY)
            {
                ModelState.AddModelError(string.Empty, Messages.SignOutBookLimitError);
                return(View(await BuildSignOutBookVM(req.LibraryId)));
            }

            await _memberService.SignOutBookAsync(req.BookId, req.LibraryId, req.MemberId);

            ViewBag.SuccessMessage = Messages.SignOutSuccessfully;
            return(View(await BuildSignOutBookVM(req.LibraryId)));
        }
Beispiel #4
0
        public async Task <int> UpdateBookTransaction(BookTransactionDto modelDto)
        {
            var entity = mapper.Map <BookTransactionDto, BookTransaction>(modelDto);

            return(await transactionService.Update(entity));
        }