Ejemplo n.º 1
0
        private static BestOfferViewModel DefaultBestOfferViewModelWithRealJewel()
        {
            var bestOfferViewModel = new BestOfferViewModel()
            {
                JewelID    = Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID,
                OfferEmail = Tests.SAMPLE_EMAIL_ADDRESS,
                OfferPrice = 2000
            };

            return(bestOfferViewModel);
        }
Ejemplo n.º 2
0
 public void EmailToCustomer(BestOfferViewModel bestOfferViewModel)
 {
     try
     {
         var model = CreateEmailModel(bestOfferViewModel);
         userMailer.BestOfferCustomer(model.Email, model).Send();
     }
     catch (Exception ex)
     {
         throw new Exception("when asked to email the best offer email to the admin an error occured:\r\n" + ex.Message);
     }
 }
Ejemplo n.º 3
0
 public void EmailToAdmin(BestOfferViewModel bestOfferViewModel)
 {
     try
     {
         var adminEmail = settingManager.AdminEmail();
         var model      = CreateEmailModel(bestOfferViewModel);
         userMailer.BestOfferAdmin(adminEmail, model).Send();
     }
     catch (Exception ex)
     {
         throw new Exception("when asked to email the best offer email to the admin an error occured:\r\n" + ex.Message);
     }
 }
Ejemplo n.º 4
0
        public ActionResult PostBestOffer(BestOfferViewModel model)
        {
            try
            {
                bestOffer.SetTodayString(DateTime.Now);
                bestOffer.EmailToAdmin(model);
                bestOffer.EmailToCustomer(model);

                return(Json(new OporationWithoutReturnValueJsonModel()));
            }
            catch (Exception ex)
            {
                return(Json(new OporationWithoutReturnValueJsonModel(true, ex.Message)));
            }
        }
Ejemplo n.º 5
0
        public BestOfferEmailTemplateViewModel CreateEmailModel(BestOfferViewModel bestOfferViewModel)
        {
            try
            {
                var jewel = jewelRepository.GetJewelByID(bestOfferViewModel.JewelID);

                var templateModel = mapper.Map <Jewel, BestOfferEmailTemplateViewModel>(jewel);
                templateModel.OfferPrice  = new Money(bestOfferViewModel.OfferPrice, Currency.Usd).Format("{1}{0:#,0}");
                templateModel.Email       = bestOfferViewModel.OfferEmail;
                templateModel.OfferNumber = jewel.ID.ToString();
                templateModel.OfferDate   = dateTime.ToShortDateString();

                return(templateModel);
            }
            catch (Exception ex)
            {
                throw new Exception("When asked to map the viewmodel from request to a viewmodel for the email an error occured: \r\n" + ex.Message);
            }
        }