예제 #1
0
        public void Approve(Guid bookId, DateTime?chooseDate = null)
        {
            var book = _repository.Get().Include(b => b.Category).FirstOrDefault(b => b.Id == bookId);

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

            book.Status     = BookStatus.Available;
            book.ChooseDate = chooseDate?.Date ?? DateTime.Today.AddDays(5);
            _repository.Update(book);

            // notifica o doador
            _booksEmailService.SendEmailBookApproved(book).Wait();

            // notifica possíveis interessados
            _booksEmailService.SendEmailBookToInterestedUsers(book).Wait();
        }