예제 #1
0
        public void InformTrackingNumber(Guid bookId, string trackingNumber)
        {
            var book = _bookRepository.Get()
                       .Include(d => d.User)
                       .Include(f => f.UserFacilitator)
                       .FirstOrDefault(id => id.Id == bookId);
            var winnerBookUser = _bookUserRepository
                                 .Get()
                                 .Include(u => u.User)
                                 .Where(bu => bu.BookId == bookId && bu.Status == DonationStatus.Donated)
                                 .FirstOrDefault();

            if (winnerBookUser == null)
            {
                throw new ShareBookException("Vencedor ainda não foi escolhido");
            }

            if (MuambatorConfigurator.IsActive)
            {
                _muambatorService.AddPackageToTrackerAsync(book, winnerBookUser.User, trackingNumber);
            }

            book.Status         = BookStatus.Sent;
            book.TrackingNumber = trackingNumber;
            _bookService.Update(book);

            if (winnerBookUser.User.AllowSendingEmail)
            {
                //Envia e-mail para avisar o ganhador do tracking number
                _bookUsersEmailService.SendEmailTrackingNumberInformed(winnerBookUser, book).Wait();
            }
        }
예제 #2
0
        public void InformTrackingNumber(Guid bookId, string trackingNumber)
        {
            var book           = _bookService.Find(bookId);
            var winnerBookUser = _bookUserRepository
                                 .Get()
                                 .Include(u => u.User)
                                 .Where(bu => bu.BookId == bookId && bu.Status == DonationStatus.Donated)
                                 .FirstOrDefault();

            if (winnerBookUser == null)
            {
                throw new ShareBookException("Vencedor ainda não foi escolhido");
            }


            book.TrackingNumber = trackingNumber;
            _bookService.Update(book);

            //Envia e-mail para avisar o ganhador do tracking number
            _bookUsersEmailService.SendEmailTrackingNumberInformed(winnerBookUser, book);
        }