Beispiel #1
0
        public void Initialize(Step3ViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Model = model;

            InitializeComponent();

            cmbOnDuplicateActions.DisplayMember = "Title";
            cmbOnDuplicateActions.DataSource    = Model.OnDuplicateOptions;
            cmbOnDuplicateActions.DataBindings.Add("SelectedItem", Model, "SelectedOnDuplicateOption", false, DataSourceUpdateMode.OnPropertyChanged);
            picOnDuplicateOptionDescription.DataBindings.Add("Visible", Model, "ShowSelectedOnDuplicateOptionDescription", false, DataSourceUpdateMode.OnPropertyChanged);
            cmbSortOptions.DisplayMember = "Title";
            cmbSortOptions.DataSource    = Model.SortOptions;
            cmbSortOptions.DataBindings.Add("SelectedItem", Model, "SelectedSortOption", false, DataSourceUpdateMode.OnPropertyChanged);
            cbxShowRandomizedFiles.DataBindings.Add("Visible", Model, "ShowRandomizedFilesVisible", false, DataSourceUpdateMode.OnPropertyChanged);
            cbxShowRandomizedFiles.DataBindings.Add("Checked", Model, "ShowRandomizedFiles", false, DataSourceUpdateMode.OnPropertyChanged);
            btnProcess.DataBindings.Add("Text", Model, "NextButtonText", false, DataSourceUpdateMode.OnPropertyChanged);

            btnPreviousStep3.Click += delegate { Invoke(OnPreviousStepClick); };

            btnProcess.Click += delegate { Invoke(OnNextStepClick); };

            cbxSaveSettings.DataBindings.Add("Checked", Model, "SaveSettings", false, DataSourceUpdateMode.OnPropertyChanged);

            IsInitialized = true;
        }
        public static Step3ViewModel MapToStep3ViewModel(Step2AlternativeViewModel source)
        {
            var target = new Step3ViewModel();

            Map(source, target);
            return(target);
        }
Beispiel #3
0
        public async Task <IActionResult> Step3(Step3ViewModel model)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await _userManager.GetUserAsync(User);

                if (!_createManager.IsStepValid(model.Id, currentUser))
                {
                    return(RedirectToAction("Step1"));
                }

                var window = _dbContext.Window.Include(x => x.WindowMeasures).SingleOrDefault(x => x.Id == model.Id);
                window.WindowDescription = model.WindowComment;

                foreach (var v in model.WindowMeasures)
                {
                    window.WindowMeasures.Add(new WindowMeasure()
                    {
                        Height = v.Height,
                        Width  = v.Width
                    });
                }
                _dbContext.Window.Update(window);
                await _dbContext.SaveChangesAsync();

                return(RedirectToAction("Step4", new { model.Id }));
            }
            return(View(model));
        }
 public static void Map(Step2AlternativeViewModel source, Step3ViewModel target)
 {
     target.PostalAddress = source.PostalAddress;
     target.State         = source.State;
     target.Postcode      = source.Postcode;
     target.Suburb        = source.Suburb;
 }
 public static void Map(Step1ViewModel source, Step3ViewModel target)
 {
     target.Name             = source.Name;
     target.OccupationLevel1 = source.OccupationLevel1;
     target.OccupationLevel2 = source.OccupationLevel2;
     target.OccupationLevel3 = source.OccupationLevel3;
 }
Beispiel #6
0
        public ActionResult Step3(int id)
        {
            Step3ViewModel model = _listingService.GetStep3ById(id);

            model.StepsProgressModel.Step      = 3;
            model.StepsProgressModel.ListingId = id;

            if (model.Step3FlatForRent != null)
            {
                return(View("FlatForRent/Step3", model));
            }
            if (model.Step3FlatForSale != null)
            {
                return(View("FlatForSale/Step3", model));
            }
            if (model.Step3HouseForRent != null)
            {
                return(View("HouseForRent/Step3", model));
            }
            if (model.Step3HouseForSale != null)
            {
                return(View("HouseForSale/Step3", model));
            }
            if (model.Step3LandForSale != null)
            {
                return(View("LandForSale/Step3", model));
            }
            if (model.Step3RoomForRent != null)
            {
                return(View("RoomForRent/Step3", model));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public async Task <IActionResult> Step3(Step3ViewModel model)
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction("Index"));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction("Step1"));
            }
            else if (!TempData.ContainsKey(TempStep2))
            {
                return(RedirectToAction("Step2"));
            }

            if (ModelState.IsValid)
            {
                string step1Json = (string)TempData.Peek(TempStep1);
                string step2Json = (string)TempData.Peek(TempStep2);

                var step1 = Newtonsoft.Json.JsonConvert.DeserializeObject <Step1ViewModel>(step1Json);
                var step2 = Newtonsoft.Json.JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);

                User user = new User();
                _mapper.Map <Step1ViewModel, User>(step1, user);
                _mapper.Map <Step2ViewModel, User>(step2, user);
                _mapper.Map <Step3ViewModel, User>(model, user);
                user.SiteId = site.Id;
                try
                {
                    await _userService.RegisterUserAsync(user, model.Password,
                                                         step2.SchoolDistrictId);

                    TempData.Remove(TempStep1);
                    TempData.Remove(TempStep2);
                    await LoginUserAsync(await _authenticationService
                                         .AuthenticateUserAsync(user.Username, model.Password));

                    return(RedirectToAction("Index", "Home"));
                }
                catch (GraException gex)
                {
                    ShowAlertDanger("Could not create your account: ", gex);
                    if (gex.Message.Contains("password"))
                    {
                        ModelState.AddModelError("Password", "Please correct the issues with your password.");
                    }
                }
            }

            PageTitle = $"{site.Name} - Join Now!";

            return(View(model));
        }
        public Step3Presenter(IApplicationController controller, IStep3View view, Step3ViewModel model)
            : base(controller, view)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            _model = model;
        }
        public async Task <IActionResult> Step3()
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction(nameof(Index)));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction(nameof(Step1)));
            }
            else if (!TempData.ContainsKey(TempStep2))
            {
                return(RedirectToAction(nameof(Step2)));
            }

            PageTitle = _sharedLocalizer[Annotations.Title.JoinNow, site.Name];

            var viewModel = new Step3ViewModel();

            var askIfFirstTime = await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskIfFirstTime);

            if (askIfFirstTime)
            {
                viewModel.AskFirstTime = EmptyNoYes();
            }

            var(askEmailSubscription, askEmailSubscriptionText) = await GetSiteSettingStringAsync(
                SiteSettingKey.Users.AskEmailSubPermission);

            if (askEmailSubscription)
            {
                viewModel.AskEmailSubscription     = EmptyNoYes();
                viewModel.AskEmailSubscriptionText = askEmailSubscriptionText;
            }

            var(askActivityGoal, defaultDailyGoal) = await GetSiteSettingIntAsync(
                SiteSettingKey.Users.DefaultDailyPersonalGoal);

            if (askActivityGoal)
            {
                viewModel.DailyPersonalGoal = defaultDailyGoal;
                string step2Json        = (string)TempData.Peek(TempStep2);
                var    step2            = JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);
                var    pointTranslation = await _pointTranslationService
                                          .GetByProgramIdAsync(step2.ProgramId.Value);

                viewModel.TranslationDescriptionPastTense =
                    pointTranslation.TranslationDescriptionPastTense.Replace("{0}", "").Trim();
                viewModel.ActivityDescriptionPlural = pointTranslation.ActivityDescriptionPlural;
            }

            return(View(viewModel));
        }
Beispiel #10
0
        public async Task <IActionResult> Step3()
        {
            var site = await GetCurrentSiteAsync();

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction("Index"));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction("Step1"));
            }
            else if (!TempData.ContainsKey(TempStep2))
            {
                return(RedirectToAction("Step2"));
            }

            PageTitle = $"{site.Name} - Join Now!";


            var viewModel = new Step3ViewModel()
            {
                AskEmailReminder = GetSiteStage() == SiteStage.RegistrationOpen &&
                                   await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskPreregistrationReminder)
            };

            var askIfFirstTime = await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskIfFirstTime);

            if (askIfFirstTime)
            {
                viewModel.AskFirstTime = EmptyNoYes();
            }

            var(askActivityGoal, defaultDailyGoal) = await GetSiteSettingIntAsync(
                SiteSettingKey.Users.DefaultDailyPersonalGoal);

            if (askActivityGoal)
            {
                viewModel.DailyPersonalGoal = defaultDailyGoal;
                string step2Json        = (string)TempData.Peek(TempStep2);
                var    step2            = JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);
                var    pointTranslation = await _pointTranslationService
                                          .GetByProgramIdAsync(step2.ProgramId.Value);

                viewModel.TranslationDescriptionPastTense =
                    pointTranslation.TranslationDescriptionPastTense.Replace("{0}", "").Trim();
                viewModel.ActivityDescriptionPlural = pointTranslation.ActivityDescriptionPlural;
            }

            return(View(viewModel));
        }
Beispiel #11
0
        public async Task <IActionResult> Step3(int id)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (!_createManager.IsStepValid(id, currentUser))
            {
                return(RedirectToAction("Step1"));
            }

            var model = new Step3ViewModel()
            {
                Id = id
            };

            return(View(model));
        }
Beispiel #12
0
        public ActionResult Step3(Step3ViewModel model)
        {
            if (ModelState.IsValid)
            {
                _listingService.SaveListingStep3(model, User.Identity.GetUserId());
                return(RedirectToAction(nameof(Step4), new { id = model.Id }));
            }

            model.StepsProgressModel.ListingId = model.Id;
            model.StepsProgressModel.Step      = 3;

            if (model.Step3FlatForRent != null)
            {
                return(View("FlatForRent/Step3", model));
            }
            if (model.Step3FlatForSale != null)
            {
                return(View("FlatForSale/Step3", model));
            }
            if (model.Step3HouseForRent != null)
            {
                return(View("HouseForRent/Step3", model));
            }
            if (model.Step3HouseForSale != null)
            {
                return(View("HouseForSale/Step3", model));
            }
            if (model.Step3LandForSale != null)
            {
                return(View("LandForSale/Step3", model));
            }
            if (model.Step3RoomForRent != null)
            {
                return(View("RoomForRent/Step3", model));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
        public ActionResult Step3(Step3ViewModel model)
        {
            if (ModelState.IsValid)
            {
                // TODO: Faran will add Billing code here

                // Once billed successfully, we will update Registration Step for user
                var now = DateTime.UtcNow;
                var user = _userService.GetByUserName(SiriusSessionPersister.UserName);
                user.AccountStatusId = (int) AccountStatus.Active;
                user.RegistrationStep = 4;

                // one month membership. This will be determined by the user input
                // but for demonstration i am setting to one month.
                var userMembership = new UserMembership
                                         {
                                             UserId = user.Id,
                                             CreatedOn = now,
                                             ExpiresOn = now.AddMonths(1),
                                             MembershipTypeId = (int) Enum.MembershipType.OneMonth
                                         };
                user.AddUserMembership(userMembership);

                user.UpdatedOn = DateTime.UtcNow;
                _userService.Update(user);

                // reset session variables
                SiriusSessionPersister.SetValues(user.Id, user.UserName, user.RegistrationStep, user.Gender);

                return RedirectToAction("Home");
            }

            return View(model);
        }
Beispiel #14
0
        public async Task <IActionResult> Step3(Step3ViewModel model)
        {
            var site = await GetCurrentSiteAsync();

            var askIfFirstTime = await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskIfFirstTime);

            if (!askIfFirstTime)
            {
                ModelState.Remove(nameof(model.IsFirstTime));
            }

            model.AskEmailReminder = GetSiteStage() == SiteStage.RegistrationOpen &&
                                     await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskPreregistrationReminder);

            if (model.AskEmailReminder && model.PreregistrationReminderRequested &&
                string.IsNullOrWhiteSpace(model.Email))
            {
                ModelState.AddModelError(nameof(model.Email),
                                         "Please enter an email address to send the reminder to.");
            }

            var(askActivityGoal, defaultDailyGoal) = await GetSiteSettingIntAsync(
                SiteSettingKey.Users.DefaultDailyPersonalGoal);

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction("Index"));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction("Step1"));
            }
            else if (!TempData.ContainsKey(TempStep2))
            {
                return(RedirectToAction("Step2"));
            }

            if (ModelState.IsValid)
            {
                string step1Json = (string)TempData.Peek(TempStep1);
                string step2Json = (string)TempData.Peek(TempStep2);

                var step1 = JsonConvert.DeserializeObject <Step1ViewModel>(step1Json);
                var step2 = JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);

                User user = new User();
                _mapper.Map <Step1ViewModel, User>(step1, user);
                _mapper.Map <Step2ViewModel, User>(step2, user);
                _mapper.Map <Step3ViewModel, User>(model, user);
                user.SiteId = site.Id;

                if (askIfFirstTime)
                {
                    user.IsFirstTime = model.IsFirstTime.Equals(DropDownTrueValue,
                                                                System.StringComparison.OrdinalIgnoreCase);
                }

                if (!model.AskEmailReminder)
                {
                    user.PreregistrationReminderRequested = false;
                }

                if (askActivityGoal && user.DailyPersonalGoal > 0)
                {
                    if (user.DailyPersonalGoal > Defaults.MaxDailyActivityGoal)
                    {
                        user.DailyPersonalGoal = Defaults.MaxDailyActivityGoal;
                    }
                }
                else
                {
                    user.DailyPersonalGoal = null;
                }

                try
                {
                    bool   useAuthCode = false;
                    string sanitized   = null;
                    if (!string.IsNullOrWhiteSpace(step1.AuthorizationCode))
                    {
                        sanitized   = _codeSanitizer.Sanitize(step1.AuthorizationCode, 255);
                        useAuthCode = await _userService.ValidateAuthorizationCode(sanitized);

                        if (useAuthCode == false)
                        {
                            _logger.LogError($"Invalid auth code used on join: {step1.AuthorizationCode}");
                        }
                    }
                    await _userService.RegisterUserAsync(user, model.Password,
                                                         allowDuringCloseProgram : useAuthCode);

                    TempData.Remove(TempStep1);
                    TempData.Remove(TempStep2);
                    var loginAttempt = await _authenticationService
                                       .AuthenticateUserAsync(user.Username, model.Password, useAuthCode);
                    await LoginUserAsync(loginAttempt);

                    if (useAuthCode)
                    {
                        string role = await _userService.ActivateAuthorizationCode(sanitized,
                                                                                   loginAttempt.User.Id);

                        if (!string.IsNullOrEmpty(role))
                        {
                            var auth = await _authenticationService
                                       .RevalidateUserAsync(loginAttempt.User.Id);

                            auth.AuthenticationMessage = $"Code applied, you are a member of the role: <strong>{role}</strong>.";
                            await LoginUserAsync(auth);
                        }
                    }

                    await _mailService.SendUserBroadcastsAsync(loginAttempt.User.Id, false, true,
                                                               true);

                    var questionnaireId = await _questionnaireService
                                          .GetRequiredQuestionnaire(loginAttempt.User.Id, loginAttempt.User.Age);

                    if (questionnaireId.HasValue)
                    {
                        HttpContext.Session.SetInt32(SessionKey.PendingQuestionnaire,
                                                     questionnaireId.Value);
                    }

                    return(RedirectToAction("Index", "Home"));
                }
                catch (GraException gex)
                {
                    ShowAlertDanger("Could not create your account: ", gex);
                    if (gex.Message.Contains("password"))
                    {
                        ModelState.AddModelError("Password", "Please correct the issues with your password.");
                    }
                }
            }

            if (askIfFirstTime)
            {
                model.AskFirstTime = EmptyNoYes();
            }

            if (askActivityGoal)
            {
                string step2Json        = (string)TempData.Peek(TempStep2);
                var    step2            = JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);
                var    pointTranslation = await _pointTranslationService
                                          .GetByProgramIdAsync(step2.ProgramId.Value);

                model.TranslationDescriptionPastTense =
                    pointTranslation.TranslationDescriptionPastTense.Replace("{0}", "").Trim();
                model.ActivityDescriptionPlural = pointTranslation.ActivityDescriptionPlural;
            }

            PageTitle = $"{site.Name} - Join Now!";

            return(View(model));
        }
Beispiel #15
0
 public Step3Page()
 {
     InitializeComponent();
     BindingContext = new Step3ViewModel(this.Navigation);
 }
        public async Task <IActionResult> Step3(Step3ViewModel model)
        {
            var site = await GetCurrentSiteAsync();

            var askIfFirstTime = await GetSiteSettingBoolAsync(SiteSettingKey.Users.AskIfFirstTime);

            if (!askIfFirstTime)
            {
                ModelState.Remove(nameof(model.IsFirstTime));
            }

            var(askEmailSubscription, askEmailSubscriptionText) = await GetSiteSettingStringAsync(
                SiteSettingKey.Users.AskEmailSubPermission);

            if (!askEmailSubscription)
            {
                ModelState.Remove(nameof(model.EmailSubscriptionRequested));
            }
            else
            {
                var subscriptionRequested = model.EmailSubscriptionRequested.Equals(
                    DropDownTrueValue, StringComparison.OrdinalIgnoreCase);
                if (subscriptionRequested && string.IsNullOrWhiteSpace(model.Email))
                {
                    ModelState.AddModelError(nameof(model.Email), " ");
                    ModelState.AddModelError(nameof(model.EmailSubscriptionRequested),
                                             _sharedLocalizer[Annotations.Required.EmailForSubscription]);
                }
            }

            var(askActivityGoal, defaultDailyGoal) = await GetSiteSettingIntAsync(
                SiteSettingKey.Users.DefaultDailyPersonalGoal);

            if (site.SinglePageSignUp)
            {
                return(RedirectToAction(nameof(Index)));
            }
            if (!TempData.ContainsKey(TempStep1))
            {
                return(RedirectToAction(nameof(Step1)));
            }
            else if (!TempData.ContainsKey(TempStep2))
            {
                return(RedirectToAction(nameof(Step2)));
            }

            if (ModelState.IsValid)
            {
                string step1Json = (string)TempData.Peek(TempStep1);
                string step2Json = (string)TempData.Peek(TempStep2);

                var step1 = JsonConvert.DeserializeObject <Step1ViewModel>(step1Json);
                var step2 = JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);

                var user = new User();
                _mapper.Map <Step1ViewModel, User>(step1, user);
                _mapper.Map <Step2ViewModel, User>(step2, user);
                _mapper.Map <Step3ViewModel, User>(model, user);
                user.SiteId = site.Id;

                if (askIfFirstTime)
                {
                    user.IsFirstTime = model.IsFirstTime.Equals(DropDownTrueValue,
                                                                StringComparison.OrdinalIgnoreCase);
                }

                if (askEmailSubscription)
                {
                    user.IsEmailSubscribed = model.EmailSubscriptionRequested.Equals(
                        DropDownTrueValue, StringComparison.OrdinalIgnoreCase);
                }

                if (askActivityGoal && user.DailyPersonalGoal > 0)
                {
                    if (user.DailyPersonalGoal > Defaults.MaxDailyActivityGoal)
                    {
                        user.DailyPersonalGoal = Defaults.MaxDailyActivityGoal;
                    }
                }
                else
                {
                    user.DailyPersonalGoal = null;
                }

                try
                {
                    bool   useAuthCode = false;
                    string sanitized   = null;
                    if (!string.IsNullOrWhiteSpace(step1.AuthorizationCode))
                    {
                        sanitized   = step1.AuthorizationCode.Trim().ToLowerInvariant();
                        useAuthCode = await _authorizationCodeService
                                      .ValidateAuthorizationCode(sanitized);

                        if (!useAuthCode)
                        {
                            _logger.LogError($"Invalid auth code used on join: {step1.AuthorizationCode}");
                        }
                    }
                    await _userService.RegisterUserAsync(user, model.Password,
                                                         allowDuringCloseProgram : useAuthCode);

                    TempData.Remove(TempStep1);
                    TempData.Remove(TempStep2);
                    var loginAttempt = await _authenticationService
                                       .AuthenticateUserAsync(user.Username, model.Password, useAuthCode);
                    await LoginUserAsync(loginAttempt);

                    if (useAuthCode)
                    {
                        string role = await _userService.ActivateAuthorizationCode(sanitized,
                                                                                   loginAttempt.User.Id);

                        if (!string.IsNullOrEmpty(role))
                        {
                            var auth = await _authenticationService
                                       .RevalidateUserAsync(loginAttempt.User.Id);

                            auth.Message = $"Code applied, you are a member of the role: {role}.";
                            await LoginUserAsync(auth);
                        }
                    }

                    await _mailService.SendUserBroadcastsAsync(loginAttempt.User.Id, false, true,
                                                               true);

                    var questionnaireId = await _questionnaireService
                                          .GetRequiredQuestionnaire(loginAttempt.User.Id, loginAttempt.User.Age);

                    if (questionnaireId.HasValue)
                    {
                        HttpContext.Session.SetInt32(SessionKey.PendingQuestionnaire,
                                                     questionnaireId.Value);
                    }

                    if (!TempData.ContainsKey(TempDataKey.UserJoined))
                    {
                        TempData.Add(TempDataKey.UserJoined, true);
                    }

                    return(RedirectToAction(nameof(HomeController.Index), HomeController.Name));
                }
                catch (GraException gex)
                {
                    ShowAlertDanger(_sharedLocalizer[Annotations.Validate.CouldNotCreate,
                                                     _sharedLocalizer[gex.Message]]);
                    if (gex.GetType() == typeof(GraPasswordValidationException))
                    {
                        ModelState.AddModelError(nameof(model.Password),
                                                 _sharedLocalizer[Annotations.Validate.PasswordIssue]);
                    }
                }
            }

            if (askIfFirstTime)
            {
                model.AskFirstTime = EmptyNoYes();
            }

            if (askEmailSubscription)
            {
                model.AskEmailSubscription     = EmptyNoYes();
                model.AskEmailSubscriptionText = askEmailSubscriptionText;
            }

            if (askActivityGoal)
            {
                string step2Json        = (string)TempData.Peek(TempStep2);
                var    step2            = JsonConvert.DeserializeObject <Step2ViewModel>(step2Json);
                var    pointTranslation = await _pointTranslationService
                                          .GetByProgramIdAsync(step2.ProgramId.Value);

                model.TranslationDescriptionPastTense =
                    pointTranslation.TranslationDescriptionPastTense.Replace("{0}", "").Trim();
                model.ActivityDescriptionPlural = pointTranslation.ActivityDescriptionPlural;
            }

            PageTitle = _sharedLocalizer[Annotations.Title.JoinNow, site.Name];

            return(View(model));
        }
 public static void Map(Step2ViewModel source, Step3ViewModel target)
 {
     target.EmailAddress = source.EmailAddress;
 }