Exemplo n.º 1
0
        public void ResendConfirmationEmail(int giftPurhcaseId)
        {
            _loggingService.LogInformation(string.Format("Resending confirmation email for gift purchase {0}", giftPurhcaseId));

            GiftPruchase giftPurchase = _giftRepository.GetGiftPurchase(giftPurhcaseId);
            Gift         gift         = _giftRepository.GetGift(giftPurchase.GiftId);
            Guest        guest        = _userRepository.GetGuestById(giftPurchase.GuestId);

            _mailService.SendPurchaseConfirmationEmail(guest, giftPurchase, gift);
        }
Exemplo n.º 2
0
        public void ReserveGift(string guestName, string guestEmail, int giftId, int quantityReserved)
        {
            _loggingService.LogInformation(string.Format("Guest {0}({1}) is reserving {2} of gift {3}", guestName, guestEmail, giftId, quantityReserved));
            Guest guest = new Guest {
                Email = guestEmail, Name = guestName, CreatedDate = DateTime.Now
            };
            var giftPurchase = new GiftPruchase(giftId, quantityReserved);

            _userRepository.InserstGuestGiftReservation(guest, giftPurchase);
            Gift gift = _giftRepository.GetGift(giftId);

            gift.PendingReservation = true;
            _giftRepository.UpdateGift(gift);
            _mailService.SendPurchaseConfirmationEmail(guest, giftPurchase, gift);
        }
Exemplo n.º 3
0
        public void SendPurchaseConfirmationEmail(Guest guest, GiftPruchase guestPurchase, Gift gift)
        {
            GiftPurchaseConfirmationEmail emailData = new GiftPurchaseConfirmationEmail(guest, guestPurchase, gift);

            try
            {
                var smtpClient  = new SmtpClient();
                var mailMessage = new MailMessage(emailData.FromAddress, emailData.ToAddress, emailData.Subject, emailData.GenerateEmailBody());
                mailMessage.IsBodyHtml = true;
                smtpClient.Send(mailMessage);
            }catch (SmtpException exception)
            {
                _logger.LogError("Could not send email", exception);
            }
        }
Exemplo n.º 4
0
        private ReservationConfirmationPage CompleteReservation(GiftPruchase reservation)
        {
            ReservationConfirmationPage reservationConfirmationPage = new ReservationConfirmationPage();

            reservation.Confirmed   = true;
            reservation.ConfirmedOn = DateTime.Now;
            _userRepository.UpdateGiftReservation(reservation);
            Gift gift = _giftRepository.GetGift(reservation.GiftId);

            gift.ConfirmReservation(reservation.Quantity);
            _giftRepository.UpdateGift(gift);
            Guest guest = _userRepository.GetGuestById(reservation.GuestId);

            reservationConfirmationPage.Guest        = guest;
            reservationConfirmationPage.GiftPruchase = reservation;
            reservationConfirmationPage.ReservedGift = gift;
            return(reservationConfirmationPage);
        }
Exemplo n.º 5
0
        public ReservationConfirmationPage ConfirmReservation(Guid confirmationId)
        {
            _loggingService.LogInformation(string.Format("Confirming reservation {0}", confirmationId));
            GiftPruchase reservation = _userRepository.GetGiftReservationByConfirmationId(confirmationId);

            if (reservation != null && !reservation.Confirmed)
            {
                return(CompleteReservation(reservation));
            }
            if (reservation == null)
            {
                return(new ReservationConfirmationPage {
                    ConfirmationErrors = new List <string> {
                        "Reservation Not found"
                    }
                });
            }
            return(new ReservationConfirmationPage {
                ConfirmationErrors = new List <string> {
                    "Already confirmed"
                }
            });
        }
 public GiftPurchaseConfirmationEmail(Guest guest, GiftPruchase guestPurchase, Gift gift)
 {
     _guest         = guest;
     _guestPurchase = guestPurchase;
     _gift          = gift;
 }