示例#1
0
        public Result <Book> Cancel(Guid bookId, bool isAdmin = false)
        {
            var book = _bookService.Find(bookId);

            if (book == null)
            {
                throw new ShareBookException(ShareBookException.Error.NotFound);
            }

            var bookUsers = _bookUserRepository.Get().Where(x => x.BookId == bookId).ToList();

            if (!isAdmin && bookUsers != null && bookUsers.Count > 0)
            {
                throw new ShareBookException("Este livro já possui interessados");
            }

            book.Approved   = false;
            book.ChooseDate = null;
            book.Canceled   = true;

            CancelBookUsersAndSendNotification(book);

            _bookService.Update(book);
            _bookUsersEmailService.SendEmailBookCanceledToAdmins(book).Wait();

            return(new Result <Book>(book));
        }
示例#2
0
        public Result <Book> Cancel(Guid bookId, bool isAdmin = false)
        {
            var book = _bookService.Find(bookId);

            if (book == null)
            {
                throw new ShareBookException(ShareBookException.Error.NotFound);
            }

            var bookUsers = _bookUserRepository.Get().Where(x => x.BookId == bookId).ToList();

            book.ChooseDate = null;
            book.Status     = BookStatus.Canceled;

            CancelBookUsersAndSendNotification(book);

            _bookService.Update(book);
            _bookUsersEmailService.SendEmailBookCanceledToAdmins(book).Wait();

            return(new Result <Book>(book));
        }