Exemplo n.º 1
0
 private static RouteValueDictionary GetRouteValues(IUrlNamedLocation location)
 {
     return(new RouteValueDictionary
     {
         { LocationKey, location.GetUrlSegment(JobAdsRoutes.SegmentSuffix) }
     });
 }
Exemplo n.º 2
0
 private static RouteValueDictionary GetRouteValues(IUrlNamedLocation location, Salary salary)
 {
     return(new RouteValueDictionary
     {
         { SalaryKey, salary.GetUrlSegment(CandidatesRoutes.SegmentSuffix) },
         { LocationKey, location.GetUrlSegment(CandidatesRoutes.SegmentSuffix) }
     });
 }
Exemplo n.º 3
0
 private static RouteValueDictionary GetRouteValues(Industry industry, IUrlNamedLocation location, int page)
 {
     return(new RouteValueDictionary
     {
         { IndustryKey, industry.GetUrlSegment(JobAdsRoutes.SegmentSuffix) },
         { LocationKey, location.GetUrlSegment(JobAdsRoutes.SegmentSuffix) },
         { PageKey, page }
     });
 }
Exemplo n.º 4
0
 public static ReadOnlyUrl GenerateJobAdsUrl(this IUrlNamedLocation location)
 {
     return(JobAdsRoutes.LocationJobAds.GenerateUrl(GetRouteValues(location)));
 }
Exemplo n.º 5
0
 public static MvcHtmlString JobAdsRouteLink(this HtmlHelper html, string linkText, IUrlNamedLocation location, Industry industry, object htmlAttributes)
 {
     return(html.RouteRefLink(linkText, JobAdsRoutes.LocationIndustryJobAds, GetRouteValues(industry, location), htmlAttributes));
 }
Exemplo n.º 6
0
 private ReadOnlyUrl GetBrowseUrl(IUrlNamedLocation location)
 {
     return(new ReadOnlyApplicationUrl(_browseBaseUrl, location.UrlName + "-candidates"));
 }
Exemplo n.º 7
0
 private ReadOnlyUrl GetBrowseUrl(IUrlNamedLocation location, Salary salary)
 {
     return(new ReadOnlyApplicationUrl(true, _browseBaseUrl, location.UrlName + "-candidates/" + GetUrlSegment(salary)));
 }
Exemplo n.º 8
0
 public BrowseCandidatesNavigation(IUrlNamedLocation location, Salary salaryBand, CandidatesPresentationModel presentation)
     : base(presentation)
 {
     Location   = location;
     SalaryBand = salaryBand;
 }
Exemplo n.º 9
0
 public static ReadOnlyUrl GenerateCandidatesUrl(this IUrlNamedLocation location, Salary salary, int?page)
 {
     return(page == null || page.Value <= 1
         ? CandidatesRoutes.LocationSalaryBandCandidates.GenerateUrl(GetRouteValues(location, salary))
         : CandidatesRoutes.PagedLocationSalaryBandCandidates.GenerateUrl(GetRouteValues(location, salary, page.Value)));
 }
Exemplo n.º 10
0
 public static ReadOnlyUrl GenerateCandidatesUrl(this IUrlNamedLocation location)
 {
     return(CandidatesRoutes.LocationCandidates.GenerateUrl(GetRouteValues(location)));
 }
Exemplo n.º 11
0
        public static MvcHtmlString CandidatesRouteLink(this HtmlHelper html, string linkText, IUrlNamedLocation location, Salary salary, int?page, object htmlAttributes)
        {
            if (!page.HasValue || page.Value <= 1)
            {
                return(html.RouteRefLink(linkText, CandidatesRoutes.LocationSalaryBandCandidates, GetRouteValues(location, salary), htmlAttributes));
            }

            return(html.RouteRefLink(linkText, CandidatesRoutes.PagedLocationSalaryBandCandidates, GetRouteValues(location, salary, page.Value), htmlAttributes));
        }
Exemplo n.º 12
0
 public static MvcHtmlString CandidatesRouteLink(this HtmlHelper html, string linkText, IUrlNamedLocation location, object htmlAttributes)
 {
     return(html.RouteRefLink(linkText, CandidatesRoutes.LocationCandidates, GetRouteValues(location), htmlAttributes));
 }
Exemplo n.º 13
0
 public static string GetUrlSegment(this IUrlNamedLocation location, string suffix)
 {
     return(location.UrlName + GetSuffix(suffix));
 }
Exemplo n.º 14
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Total = Model.Results.TotalCandidates;

            // Determine start and end.

            var items = Model.Presentation.Pagination.Items ?? Model.Results.CandidateIds.Count;

            CurrentPage = Model.Presentation.Pagination.Page ?? 1;
            TotalPages  = (int)Math.Ceiling((double)Total / items);

            // Only show a maximum number of page links.

            if (TotalPages <= MaxPages)
            {
                FirstPage = 1;
                LastPage  = TotalPages;
            }
            else
            {
                if (CurrentPage < MaxPages / 2 + 1)
                {
                    // If at left end ...

                    FirstPage = 1;
                    LastPage  = MaxPages;
                }
                else if (CurrentPage > TotalPages - MaxPages / 2)
                {
                    // If at right end ...

                    FirstPage = TotalPages - MaxPages + 1;
                    LastPage  = TotalPages;
                }
                else
                {
                    // If in the middle ...

                    FirstPage = CurrentPage < MaxPages / 2 + 1 ? 1 : CurrentPage - MaxPages / 2;
                    LastPage  = CurrentPage > TotalPages - MaxPages / 2 ? TotalPages : CurrentPage + MaxPages / 2;
                }
            }

            Start = ((CurrentPage - 1) * items) + 1;
            End   = Start + Model.Results.CandidateIds.Count - 1;

            // Set up browse parameters.

            if (Model is BrowseListModel)
            {
                // Extract the location and industry from the criteria.

                var location = Model.Criteria.Location;
                if (location.IsFullyResolved)
                {
                    _location = location.NamedLocation as IUrlNamedLocation;
                }

                _salary = Model.Criteria.Salary;
            }
        }
Exemplo n.º 15
0
 public static ReadOnlyUrl GenerateJobAdsUrl(this IUrlNamedLocation location, Industry industry, int?page)
 {
     return(page == null || page.Value <= 1
         ? JobAdsRoutes.LocationIndustryJobAds.GenerateUrl(GetRouteValues(industry, location))
         : JobAdsRoutes.PagedLocationIndustryJobAds.GenerateUrl(GetRouteValues(industry, location, page.Value)));
 }
Exemplo n.º 16
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Total = Model.Results.TotalJobAds;

            // Determine start and end.

            ItemsPerPage = Model.Presentation.Pagination.Items ?? Reference.DefaultItemsPerPage;

            CurrentPage = Model.Presentation.Pagination.Page ?? 1;
            TotalPages  = (int)Math.Ceiling((double)Total / ItemsPerPage);

            // Only show a maximum number of page links.

            if (TotalPages <= MaxPages)
            {
                FirstPage = 1;
                LastPage  = TotalPages;
            }
            else
            {
                if (CurrentPage < MaxPages / 2 + 1)
                {
                    // If at left end ...

                    FirstPage = 1;
                    LastPage  = MaxPages;
                }
                else if (CurrentPage > TotalPages - MaxPages / 2)
                {
                    // If at right end ...

                    FirstPage = TotalPages - MaxPages + 1;
                    LastPage  = TotalPages;
                }
                else
                {
                    // If in the middle ...

                    FirstPage = CurrentPage < MaxPages / 2 + 1 ? 1 : CurrentPage - MaxPages / 2;
                    LastPage  = CurrentPage > TotalPages - MaxPages / 2 ? TotalPages : CurrentPage + MaxPages / 2;
                }
            }

            Start = ((CurrentPage - 1) * ItemsPerPage) + 1;
            End   = Start + ItemsPerPage - 1;
            if (End > Total)
            {
                End = Total;
            }

            // Set up browse parameters.

            if (Model.ListType == JobAdListType.BrowseResult)
            {
                // Extract the location and industry from the criteria.

                var criteria = ((JobAdSearchListModel)Model).Criteria;
                var location = criteria.Location;
                if (location.IsFullyResolved)
                {
                    _location = location.NamedLocation as IUrlNamedLocation;
                }

                if (!criteria.IndustryIds.IsNullOrEmpty() && criteria.IndustryIds.Count == 1)
                {
                    _industry = (from i in Model.Industries where i.Id == criteria.IndustryIds[0] select i).SingleOrDefault();
                }
            }
        }
Exemplo n.º 17
0
 private ReadOnlyUrl GetBrowseUrl(IUrlNamedLocation location, Industry industry)
 {
     return(new ReadOnlyApplicationUrl(_browseBaseUrl, location.UrlName + "-jobs/" + industry.UrlName + "-jobs"));
 }