public ActionResult ResetOptIn()
        {
            var vm = new OptInViewModel
            {
                oiResult = @"Check your inbox for your requested free document "
                           + "(email will come from '*****@*****.**')"
            };

            return(PartialView("_OptInPartial", vm));
        }
Ejemplo n.º 2
0
        //
        // GET: /OptIn/ -- restaurant guide optIn
        public Object OptIn(OptInViewModel viewModel)
        {
            _vm.FirstName    = string.Empty;
            _vm.LastName     = string.Empty;
            _vm.EmailAddress = string.Empty;

            switch (this.Request.UrlReferrer.Segments[2])
            {
            case "Celiac":
                _vm.oiSource   = "CeliacCC Opt-In";
                _vm.oiDocument = "CeliacCrashCourse.pdf";
                break;

            case "PCOS":
                _vm.oiSource   = "PCOS Opt-In";
                _vm.oiDocument = "PCOSresources.pdf";
                break;

            case "Sports":
                _vm.oiSource   = "Sports Opt-In";
                _vm.oiDocument = "EnduranceAthleteNutritionGuide.pdf";
                break;

            case "Vegetarian":
                _vm.oiSource   = "Vegetarian Opt-In";
                _vm.oiDocument = "B12-Consumer.pdf";
                break;

            case "Weight":
                _vm.oiSource   = "Weight Management Opt-In";
                _vm.oiDocument = "GeneSnp.pdf";
                break;
            }

            try
            {
                if (ModelState.IsValid && string.IsNullOrEmpty(viewModel.botCheck))
                {
                    viewModel.Save(_vm);
                    return(RedirectToAction("ResetOptIn"));
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                ViewData["Exception"] = "Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace;
#endif
            }
            return(PartialView("_OptInPartial", _vm));
        }
        public ActionResult Index()
        {
            _vm = new OptInViewModel
            {
                FirstName    = string.Empty,
                LastName     = string.Empty,
                EmailAddress = string.Empty,
                oiSource     = @"Restaurant Opt-In",
                oiDocument   = @"RestaurantMeals.pdf",
                oiMessage    = @"Sign up for our newsletter and receive a free report on restaurant meals!",
                oiResult     = string.Empty
            };

            return(View("Index", _vm));
        }
        //
        // GET: /OptIn/ -- restaurant guide optIn
        public ActionResult OptIn(OptInViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid && string.IsNullOrEmpty(viewModel.botCheck))
                {
                    viewModel.Save(_vm);
                    return(RedirectToAction("ResetOptIn"));
                }
            }
            catch (Exception ex)
            {
 #if DEBUG
                ViewData["Exception"] = "Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace;
#endif
            }
            return(PartialView("_OptInPartial", _vm));
        }
Ejemplo n.º 5
0
        //
        // Register for Webinar - Ajax partial postback
        public ActionResult Register(OptInViewModel viewModel)
        {
            var sourceRepository = new SourceRepository();

            if (ModelState.IsValid && string.IsNullOrEmpty(viewModel.botCheck))
            {
                try
                {
                    var contact = new Contact
                    {
                        FirstName    = viewModel.FirstName,
                        LastName     = viewModel.LastName,
                        EmailAddress = viewModel.EmailAddress,
                        SubmitDate   = DateTime.Now,
                        optIn        = true
                    };

                    var source = sourceRepository.FindByName("PCOS Webinar Opt-In");
                    contact.SourceID = source.ID;
                    contact.Comments = source.Notes;

                    contactRepository.InsertOrUpdate(contact);
                    contactRepository.Save();

                    var email          = new Email();
                    var emailViewModel = FormatEmail(contact);
                    email.InboundMessage(emailViewModel);

                    string docPath      = Server.MapPath("/Content/Documents/PCOSWebinarInstructions.htm");
                    var    instructions = MvcHtmlString.Create(System.IO.File.ReadAllText(docPath, System.Text.Encoding.UTF8));
                    email.SendWebinarInstructions(emailViewModel, instructions);
                }
                catch (Exception ex)
                {
                    base.ViewData["Exception"] = "Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace;
                }
                return(RedirectToAction("Thanks"));
            }
            else
            {
                return(PartialView("_WebinarOptInPartial"));
            }
        }
        // GET: /OptIn/ -- restaurant guide optIn
        public ActionResult OptIn(OptInViewModel viewModel)
        {
            viewModel.oiMessage  = PromoDisplayVM.oiMessage;
            viewModel.oiDocument = PromoDisplayVM.oiDocument;
            viewModel.oiSource   = PromoDisplayVM.Code + " Opt-In";
            try
            {
                if (ModelState.IsValid && string.IsNullOrEmpty(viewModel.botCheck))
                {
                    viewModel.Save(viewModel);

                    return(RedirectToAction("ResetOptIn", viewModel));
                }
            }
            catch (Exception ex)
            {
 #if DEBUG
                ViewData["Exception"] = "Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace;
#endif
            }
            return(PartialView("_OptInPartial", viewModel));
        }