Пример #1
0
        public ActionResult Search(JobAdSearchCriteria criteria, JobAdsPresentationModel presentation)
        {
            var member = CurrentMember;

            // Prepare.

            var criteriaIsEmpty = PrepareCriteria(criteria);

            presentation = PreparePresentationModel(presentation);

            if (criteriaIsEmpty || !ModelState.IsValid)
            {
                // Set up defaults.

                SetDefaults(criteria);

                if (member != null && MemberContext.ShowUpdatedTermsReminder())
                {
                    ModelState.AddModelConfirmation("We've made some changes to our terms and conditions. You can review them <a href=\"" + SupportRoutes.Terms.GenerateUrl() + "\">here</a>.");
                }

                return(View(GetSearchModel(criteria, presentation)));
            }

            MemberContext.CurrentSearch = new JobAdSearchNavigation(criteria, presentation);
            MemberContext.IsNewSearch   = true;

            return(RedirectToRoute(SearchRoutes.Results));
        }
Пример #2
0
        public ActionResult PostDeleteSearch(Guid searchId)
        {
            // Used to 'unsubscribe' from an anonymous user's alert.

            var model = new DeleteSearchModel();

            try
            {
                model.Search = GetSearch(searchId);

                // Given that an anonymous user could be responding to an email alert on different devices
                // and that they don't have to sign in get the owner directly from the search itself.

                var owner = _anonymousUsersQuery.GetContact(model.Search.OwnerId);
                if (owner == null)
                {
                    throw new ValidationErrorsException(new NotFoundValidationError("alert id", searchId));
                }

                // Delete it.

                _jobAdSearchAlertsCommand.DeleteJobAdSearch(owner.Id, searchId);
                model.HasDeleted = true;

                ModelState.AddModelConfirmation("You have now been unsubscribed from this job alert.");
                return(View(model));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View(model));
        }
Пример #3
0
        public ActionResult Search(MemberSearchCriteria criteria, CandidatesPresentationModel presentation, bool?createEmailAlert)
        {
            var employer = CurrentEmployer;

            // Prepare.

            var criteriaIsEmpty = PrepareCriteria(employer, criteria);

            presentation = PreparePresentationModel(presentation);

            if (criteriaIsEmpty || !ModelState.IsValid)
            {
                // Set up defaults.

                SetDefaults(criteria);

                if (CurrentEmployer != null && EmployerContext.ShowUpdatedTermsReminder())
                {
                    ModelState.AddModelConfirmation("We've made some changes to our terms and conditions. You can review them <a href=\"" + SupportRoutes.Terms.GenerateUrl() + "\">here</a>.");
                }

                return(View(GetSearchList(employer, createEmailAlert, criteria, presentation)));
            }

            // On a new search reset.

            EmployerContext.CurrentSearch = new MemberSearchNavigation(criteria, presentation);
            ResetSearch(employer, null);

            return(createEmailAlert != null
                ? RedirectToRoute(SearchRoutes.Results, new { createEmailAlert })
                : RedirectToRoute(SearchRoutes.Results));
        }
Пример #4
0
        public ActionResult Verification(string verificationCode)
        {
            string loginId = null;

            try
            {
                if (string.IsNullOrEmpty(verificationCode))
                {
                    ModelState.AddModelError(new RequiredValidationError("verificationCode"), new ActivationErrorHandler());
                    return(View(new ActivationModel {
                        Login = new Login()
                    }));
                }

                // Activate.

                var memberId = _accountVerificationsCommand.Verify(verificationCode);
                if (memberId == null)
                {
                    ModelState.AddModelError(new NotFoundValidationError("verificationCode", verificationCode), new ActivationErrorHandler());
                    return(View(new ActivationModel {
                        Login = new Login()
                    }));
                }

                // Checked whether logged in.

                var currentUser = CurrentRegisteredUser;
                if (currentUser == null)
                {
                    loginId = GetLoginId(memberId.Value);
                }
                else
                {
                    if (currentUser.Id == memberId)
                    {
                        // Update the user.

                        _authenticationManager.UpdateUser(HttpContext, currentUser, true);
                        return(RedirectToUrl(GetLoggedInMemberUrl(currentUser)));
                    }
                }

                ModelState.AddModelConfirmation("Your email address is now verified, please log in.");
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new ActivationErrorHandler());
            }

            return(View(new ActivationModel {
                Login = new Login {
                    LoginId = loginId
                }
            }));
        }
Пример #5
0
        public ActionResult PostUnsubscribe(UnsubscribeRequestModel requestModel)
        {
            var model = new UnsubscribeModel {
                Login = new Login()
            };

            try
            {
                Prepare(requestModel, model);

                // Unsubscribe.

                _settingsCommand.SetFrequency(requestModel.UserId.Value, model.Category.Id, Frequency.Never);
                model.HasUnsubscribed = true;

                ModelState.AddModelConfirmation("You have now been unsubscribed from this type of email.");
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View(model));
        }