Exemplo n.º 1
0
 public static void AddServerRules(this AbstractValidator <ApprenticeshipSearchViewModel> validator)
 {
     validator.RuleFor(x => x.Location)
     .Length(3, 99)
     .When(x => x.Location != null && !x.Location.Any(Char.IsDigit) && !VacancyHelper.IsVacancyReference(x.Keywords))
     .WithMessage(ApprenticeshipSearchViewModelMessages.LocationMessages.LengthErrorText);
 }
 public static void AddLocationRules(this AbstractValidator <TraineeshipSearchViewModel> validator)
 {
     // NOTE: no message here, 'no results' help text provides suggestions to user.
     validator.RuleFor(x => x.Location)
     .Must(HaveLatAndLongPopulated)
     .When(x => !VacancyHelper.IsVacancyReference(x.ReferenceNumber));
 }
Exemplo n.º 3
0
 public static void AddLocationRules(this AbstractValidator <ApprenticeshipSearchViewModel> validator)
 {
     // NOTE: no message here, 'no results' help text provides suggestions to user.
     validator.RuleFor(x => x.Location)
     .Must(HaveLatAndLongPopulated)
     .When(x => x.SearchMode == ApprenticeshipSearchMode.Keyword || x.SearchMode == ApprenticeshipSearchMode.Category)
     .When(x => !VacancyHelper.IsVacancyReference(x.Keywords));
 }
Exemplo n.º 4
0
        public static void AddServerRules(this AbstractValidator <ApprenticeshipSearchViewModel> validator)
        {
            validator.RuleFor(x => x.Location)
            .Length(3, 99)
            .When(IsKeywordOrCategorySearch)
            .When(x => x.Location != null && !x.Location.Any(Char.IsDigit) && !VacancyHelper.IsVacancyReference(x.Keywords))
            .WithMessage(ApprenticeshipSearchViewModelMessages.LocationMessages.LengthErrorText);

            validator.RuleFor(x => x.SavedSearchId)
            .NotEmpty()
            .When(x => x.SearchMode == ApprenticeshipSearchMode.SavedSearches)
            .WithMessage(ApprenticeshipSearchViewModelMessages.SavedSearchMessages.RequiredErrorText);
        }
Exemplo n.º 5
0
        public static void AddCommonRules(this AbstractValidator <ApprenticeshipSearchViewModel> validator)
        {
            validator.RuleFor(x => x.Location)
            .NotEmpty()
            .When(x => !VacancyHelper.IsVacancyReference(x.Keywords))
            .WithMessage(ApprenticeshipSearchViewModelMessages.LocationMessages.RequiredErrorText)
            .Length(2, 99)
            .WithMessage(ApprenticeshipSearchViewModelMessages.LocationMessages.LengthErrorText)
            .Matches(ApprenticeshipSearchViewModelMessages.LocationMessages.WhiteList)
            .WithMessage(ApprenticeshipSearchViewModelMessages.LocationMessages.WhiteListErrorText);

            validator.RuleFor(x => x.Keywords)
            .Matches(ApprenticeshipSearchViewModelMessages.KeywordMessages.WhiteList)
            .WithMessage(ApprenticeshipSearchViewModelMessages.KeywordMessages.WhiteListErrorText);

            validator.RuleFor(x => x.Category)
            .NotEmpty()
            .When(x => x.SearchMode == ApprenticeshipSearchMode.Category)
            .WithMessage(ApprenticeshipSearchViewModelMessages.CategoryMessages.RequiredErrorText);
        }
Exemplo n.º 6
0
 public void IsVacancyReference(string value, bool expectTrue)
 {
     Assert.That(VacancyHelper.IsVacancyReference(value), Is.EqualTo(expectTrue));
 }
Exemplo n.º 7
0
        public override void Execute()
        {
            WriteLiteral("\r\n");


            #line 7 "..\..\Views\ApprenticeshipSearch\Results.cshtml"

            ViewBag.Title = "Results - Find an apprenticeship";
            Layout        = "~/Views/Shared/_Layout.cshtml";

            var locationTypeLink = Model.VacancySearch.LocationType == ApprenticeshipLocationType.National ? Url.Action("results", new ApprenticeshipSearchViewModel(Model.VacancySearch)
            {
                LocationType = ApprenticeshipLocationType.NonNational, SearchAction = SearchAction.LocationTypeChanged, PageNumber = 1
            }) : Url.Action("results", new ApprenticeshipSearchViewModel(Model.VacancySearch)
            {
                LocationType = ApprenticeshipLocationType.National, SearchAction = SearchAction.LocationTypeChanged, SortType = VacancySearchSortType.Distance, PageNumber = 1
            });

            string resultMessage;
            string nationalResultsMessage;

            if (Model.TotalLocalHits == 0)
            {
                resultMessage = "";
            }
            else if (Model.TotalLocalHits == 1)
            {
                if (Model.VacancySearch.LocationType == ApprenticeshipLocationType.National)
                {
                    resultMessage = "We've found <b class=\"bold-medium\">1</b> <a id='localLocationTypeLink' href=" + locationTypeLink + ">apprenticeship in your selected area</a>.";
                }
                else
                {
                    resultMessage = "We've found <b class=\"bold-medium\">1</b> apprenticeship in your selected area.";
                }
            }
            else
            {
                if (Model.VacancySearch.LocationType == ApprenticeshipLocationType.National)
                {
                    var message = "We've found <b class=\"bold-medium\">{0}</b> <a id='localLocationTypeLink' href=" + locationTypeLink + ">apprenticeships in your selected area</a>.";
                    resultMessage = string.Format(message, Model.TotalLocalHits);
                }
                else
                {
                    resultMessage = string.Format("We've found <b class=\"bold-medium\">{0}</b> apprenticeships in your selected area.", Model.TotalLocalHits);
                }
            }

            if (Model.TotalNationalHits == 0)
            {
                nationalResultsMessage = "";
            }
            else
            {
                var nationalResultsMessagePrefix = Model.TotalLocalHits == 0 ? "We've found" : "We've also found";

                if (Model.TotalNationalHits == 1)
                {
                    if (Model.VacancySearch.LocationType == ApprenticeshipLocationType.NonNational)
                    {
                        nationalResultsMessage = string.Format("{1} <a id='nationwideLocationTypeLink' href={0}>1 apprenticeship nationwide</a>.", locationTypeLink, nationalResultsMessagePrefix);
                    }
                    else
                    {
                        nationalResultsMessage = nationalResultsMessagePrefix + " 1 apprenticeship nationwide.";
                    }
                }
                else
                {
                    if (Model.VacancySearch.LocationType == ApprenticeshipLocationType.NonNational)
                    {
                        nationalResultsMessage = string.Format("{2} <a id='nationwideLocationTypeLink' href={1}>{0} apprenticeships nationwide</a>.", Model.TotalNationalHits, locationTypeLink, nationalResultsMessagePrefix);
                    }
                    else
                    {
                        nationalResultsMessage = string.Format("{1} {0} apprenticeships nationwide.", Model.TotalNationalHits, nationalResultsMessagePrefix);
                    }
                }
            }


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n");

            DefineSection("metatags", () => {
                WriteLiteral("\r\n    ");

                WriteLiteral("\r\n    <meta");

                WriteLiteral(" name=\"WT.oss_r\"");

                WriteAttribute("content", Tuple.Create(" content=\"", 3558), Tuple.Create("\"", 3589)

            #line 82 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                               , Tuple.Create(Tuple.Create("", 3568), Tuple.Create <System.Object, System.Int32>(Model.TotalLocalHits

            #line default
            #line hidden
                                                                                                                 , 3568), false)
                               );

                WriteLiteral(" />\r\n");
            });

            WriteLiteral("\r\n<div");

            WriteLiteral(" class=\"search-results-wrapper grid-wrapper\"");

            WriteLiteral(">\r\n    <div");

            WriteLiteral(" class=\"hgroup\"");

            WriteLiteral(">\r\n        <h1");

            WriteLiteral(" class=\"heading-xlarge\"");

            WriteLiteral(">Search results</h1>\r\n        <div");

            WriteLiteral(" id=\"vacancy-result-summary\"");

            WriteLiteral(">\r\n            <p");

            WriteLiteral(" id=\"result-message\"");

            WriteLiteral(" class=\"small-btm-margin\"");

            WriteLiteral(">");


            #line 89 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
            Write(Html.Raw(resultMessage));


            #line default
            #line hidden
            WriteLiteral("</p>\r\n            <p");

            WriteLiteral(" id=\"national-results-message\"");

            WriteLiteral(">");


            #line 90 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
            Write(Html.Raw(nationalResultsMessage));


            #line default
            #line hidden
            WriteLiteral("</p>\r\n        </div>\r\n    </div>\r\n\r\n");


            #line 94 "..\..\Views\ApprenticeshipSearch\Results.cshtml"


            #line default
            #line hidden

            #line 94 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
            using (Html.BeginRouteForm(CandidateRouteNames.ApprenticeshipResults, FormMethod.Get))
            {
                Html.Partial("ValidationSummary", ViewData.ModelState);
                Html.RenderPartial("_searchUpdate", Model.VacancySearch);


            #line default
            #line hidden
                WriteLiteral("        <section");

                WriteLiteral(" class=\"grid grid-2-3\"");

                WriteLiteral(">\r\n");


            #line 99 "..\..\Views\ApprenticeshipSearch\Results.cshtml"


            #line default
            #line hidden

            #line 99 "..\..\Views\ApprenticeshipSearch\Results.cshtml"

                if (Model.TotalLocalHits == 0 && Model.TotalNationalHits == 0)
                {
            #line default
            #line hidden
                    WriteLiteral("                    <p");

                    WriteLiteral(" id=\"search-no-results-title\"");

                    WriteLiteral(">There are currently no apprenticeships that match your search.</p>\r\n");

                    WriteLiteral("                    <p>Try editing your search:</p>\r\n");

                    WriteLiteral("                    <ul");

                    WriteLiteral(" id=\"search-no-results\"");

                    WriteLiteral(">\r\n");


            #line 105 "..\..\Views\ApprenticeshipSearch\Results.cshtml"


            #line default
            #line hidden

            #line 105 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                    if (Model.VacancySearch.SearchMode == ApprenticeshipSearchMode.Keyword)
                    {
                        if (VacancyHelper.IsVacancyReference(Model.VacancySearch.Keywords))
                        {
            #line default
            #line hidden
                            WriteLiteral("                                <li");

                            WriteLiteral(" id=\"search-no-results-reference-number\"");

                            WriteLiteral(">try a different reference number</li>\r\n");


            #line 110 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                        }
                        else
                        {
            #line default
            #line hidden
                            WriteLiteral("                                <li");

                            WriteLiteral(" id=\"search-no-results-keywords\"");

                            WriteLiteral(">using different keywords</li>\r\n");


            #line 114 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                        }
                    }


            #line default
            #line hidden
                    WriteLiteral("                        ");


            #line 116 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                    if (Model.VacancySearch.SearchMode == ApprenticeshipSearchMode.Category)
                    {
                        if (Model.VacancySearch.SubCategories == null || Model.VacancySearch.SubCategories.Length == 0)
                        {
            #line default
            #line hidden
                            WriteLiteral("                                <li");

                            WriteLiteral(" id=\"search-no-results-category\"");

                            WriteLiteral(">try a different category</li>\r\n");


            #line 121 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                        }
                        else
                        {
            #line default
            #line hidden
                            WriteLiteral("                                <li");

                            WriteLiteral(" id=\"search-no-results-sub-category\"");

                            WriteLiteral(">select a different sub-category or sub-categories</li>\r\n");


            #line 125 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                        }
                    }


            #line default
            #line hidden
                    WriteLiteral("                        <li>expanding your search location</li>\r\n");


            #line 128 "..\..\Views\ApprenticeshipSearch\Results.cshtml"


            #line default
            #line hidden

            #line 128 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                    if (Model.VacancySearch.ApprenticeshipLevel != "All")
                    {
            #line default
            #line hidden
                        WriteLiteral("                            <li");

                        WriteLiteral(" id=\"search-no-results-apprenticeship-levels\"");

                        WriteLiteral(">using a different level, or change to all levels</li>\r\n");


            #line 131 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("                    </ul>\r\n");


            #line 133 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                }
                else
                {
            #line default
            #line hidden
                    WriteLiteral("                    <div");

                    WriteLiteral(" id=\"pagedList\"");

                    WriteLiteral(">\r\n");


            #line 137 "..\..\Views\ApprenticeshipSearch\Results.cshtml"


            #line default
            #line hidden

            #line 137 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                    Html.RenderPartial("_searchResults", Model);

            #line default
            #line hidden
                    WriteLiteral("\r\n                    </div>\r\n");


            #line 139 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("\r\n        </section>\r\n");


            #line 142 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("</div>\r\n\r\n");

            DefineSection("scripts", () => {
                WriteLiteral("\r\n    <script");

                WriteLiteral(" type=\"text/javascript\"");

                WriteLiteral(" src=\"https://maps.googleapis.com/maps/api/js?v=3\"");

                WriteLiteral("></script>\r\n\r\n");

                WriteLiteral("    ");


            #line 149 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                Write(Scripts.Render("~/bundles/nas/locationsearch"));


            #line default
            #line hidden
                WriteLiteral("\r\n    <script");

                WriteLiteral(" type=\"text/javascript\"");

                WriteLiteral(">\r\n        $(function () {\r\n            $(\"#Location\").locationMatch({\r\n         " +
                             "       url: \'");


            #line 153 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                Write(Url.Action("location", "Location"));


            #line default
            #line hidden
                WriteLiteral(@"',
                longitude: '#Longitude',
                latitude: '#Latitude',
                latlonhash: '#Hash'
            });

            $('#sort-results').change(function () {

                $('#SearchAction').val(""Sort"");
                $(""form"").submit();
            });

            $('#results-per-page').change(function () {
                $('#SearchAction').val(""Sort"");
                $(""form"").submit();
            });

            $('#search-button').click(function () {
                $('#LocationType').val(""NonNational"");
            });
            $(""#search-tab-control"").click(function () {
                $(""#SearchMode"").val(""Keyword"");
            });

            $(""#browse-tab-control"").click(function () {
                $(""#SearchMode"").val(""Category"");
            });
        });
    </script>


");

                WriteLiteral("    ");


            #line 184 "..\..\Views\ApprenticeshipSearch\Results.cshtml"
                Write(Scripts.Render("~/bundles/nas/resultsMap"));


            #line default
            #line hidden
                WriteLiteral("\r\n\r\n");
            });
        }