public ActionResult First(Guid regionGuid, Guid selectionDateGuid)
        {
            this.companyViewModel = new CompanyViewModel();
            this.companyViewModel.RegionGuid = regionGuid;
            this.companyViewModel.SelectedDateGuid = selectionDateGuid;

            BuildViewModel(this.companyViewModel);

            return View(this.companyViewModel);
        }
 public CompanyController(IEmailService emailService, IHandsetOpotunitiesService handsetOpotunitiesService, ITimeFrameService timeFrameService, IDeviceService deviceService, IRegionService regionService, ISelectionDateService selectionDateService, ILumiaTrialFormDataService lumiaTrialFormDataService)
 {
     this.deviceService = deviceService;
     this.regionService = regionService;
     this.selectionDateService = selectionDateService;
     this.lumiaTrialFormDataService = lumiaTrialFormDataService;
     this.timeFrameService = timeFrameService;
     this.handsetOpotunitiesService = handsetOpotunitiesService;
     this.emailService = emailService;
     this.companyViewModel = new CompanyViewModel();
 }
        public ActionResult First(CompanyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                BuildViewModel(model);
                return View(model);
            }

            this.companyViewModel = model;
            BuildViewModel(this.companyViewModel);

            return View("Second", this.companyViewModel);
        }
        public ActionResult Second(CompanyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                BuildViewModel(model);
                return View(model);
            }

            model.SelectedRegionName = regionService.Get(model.RegionGuid).Name;
            model.SelectionDateName = selectionDateService.Get(model.SelectedDateGuid).Selection.ToShortDateString();
            model.SelectedHandsetOpotunityName = this.handsetOpotunitiesService.Get(model.HandsetOpotunitiesId).Name;

            //this.emailService.Send(model);
            return RedirectToAction("FormComplete", new { regionGuid = model.RegionGuid});
        }
Пример #5
0
        private string BuildEmailBody(CompanyViewModel model)
        {
            var body = string.Format("Region: {0} Selection Date:  {1} " +
                                     "Contact Name: {2} Email Address:{3} Address: {4} Number: {5} Postcode: {6} Job Title: {7} Company Name: {8} Handset Opotunitiy: {9} Refresh Date: {10} Handset Provider: {11} " +
                                     "Handset Operator: {12}  Accepted Terms: {13}  Share Information: {14}",
                model.SelectedRegionName, model.SelectionDateName, model.ContactName, model.EmailAddress, model.Address,
                model.Number, model.PostCode, model.JobTitle, model.CompanyName, model.SelectedHandsetOpotunityName,
                model.SelectionDateName, model.CurrentHandsetProvider, model.CurrentHandsetOperator,
                model.IsTermsAcepted,
                model.IsSharedInformationAllowed);

            model.Devices.ForEach(x =>
            {
                body += string.Format("Device Selection - Name: {0} Enabled: {1} Selected: {2} {3} ", x.Name, x.Enabled, x.Checked, Environment.NewLine);
            });

            return body;
        }
Пример #6
0
        public void Send(CompanyViewModel model)
        {
            string email = Resources.EmailSettings.Email;
            string password = Resources.EmailSettings.Password;

            var loginInfo = new NetworkCredential(email, password);
            var msg = new MailMessage();
            var smtpClient = new SmtpClient(Resources.EmailSettings.SMTP, Convert.ToInt32(Resources.EmailSettings.Port));

            msg.From = new MailAddress(email);
            msg.To.Add(new MailAddress(model.EmailAddress));
            msg.Subject = "Lumia Trial";
            msg.Body = this.BuildEmailBody(model);
            msg.IsBodyHtml = true;

            smtpClient.EnableSsl = true;
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = loginInfo;
            smtpClient.Send(msg);
        }
 private void BuildViewModel(CompanyViewModel model)
 {
     model.TimeFrame = this.timeFrameService.Get(model.RegionGuid);
     model.Devices = this.deviceService.GetAll(model.RegionGuid).Select(x => new DeviceViewModel
     {
         Id = x.Id,
         Name = x.Name,
         Enabled = x.isEnabled,
         Checked = false
     }).ToList();
     model.HandsetOpotunities = this.handsetOpotunitiesService.GetAll().ToList();
     model.SelectedHandsetRefreshDate = this.selectionDateService.Get(model.SelectedDateGuid).Selection.ToLongDateString();
 }