コード例 #1
0
 public ApprenticeshipSearchViewModel(ApprenticeshipSearchViewModel viewModel) : base(viewModel)
 {
     Keywords            = viewModel.Keywords;
     LocationType        = viewModel.LocationType;
     ApprenticeshipLevel = viewModel.ApprenticeshipLevel;
     Category            = viewModel.Category;
     SubCategories       = viewModel.SubCategories;
     SearchMode          = viewModel.SearchMode;
 }
コード例 #2
0
 public LocationViewModel(ApprenticeshipSearchViewModel model)
 {
     if (model != null)
     {
         Name      = model.Location;
         Longitude = model.Longitude.GetValueOrDefault();
         Latitude  = model.Latitude.GetValueOrDefault();
     }
 }
コード例 #3
0
 public ApprenticeshipSearchViewModel(ApprenticeshipSearchViewModel viewModel) : base(viewModel)
 {
     Keywords                   = viewModel.Keywords;
     LocationType               = viewModel.LocationType;
     ApprenticeshipLevel        = viewModel.ApprenticeshipLevel;
     Category                   = viewModel.Category;
     SubCategories              = viewModel.SubCategories;
     SearchMode                 = viewModel.SearchMode;
     SearchField                = viewModel.SearchField;
     SavedSearches              = viewModel.SavedSearches;
     DisplaySubCategory         = viewModel.DisplaySubCategory;
     DisplayDescription         = viewModel.DisplayDescription;
     DisplayDistance            = viewModel.DisplayDistance;
     DisplayClosingDate         = viewModel.DisplayClosingDate;
     DisplayStartDate           = viewModel.DisplayStartDate;
     DisplayApprenticeshipLevel = viewModel.DisplayApprenticeshipLevel;
     DisplayWage                = viewModel.DisplayWage;
     LocationSearches           = Enumerable.Empty <ApprenticeshipSearchViewModel>();
 }
コード例 #4
0
        public static ApprenticeshipSearchViewModel FromSearchUrl(string searchUrl)
        {
            if (string.IsNullOrWhiteSpace(searchUrl))
            {
                return(null);
            }

            var searchUri         = new Uri(new Uri("http://base"), searchUrl);
            var queryStringParams = HttpUtility.ParseQueryString(searchUri.Query);

            var searchModel = new ApprenticeshipSearchViewModel();

            searchModel.SearchMode = queryStringParams.Get("SearchMode") != null
                ? (ApprenticeshipSearchMode)Enum.Parse(typeof(ApprenticeshipSearchMode), queryStringParams.Get("SearchMode"))
                : ApprenticeshipSearchMode.Keyword;

            searchModel.SortType = queryStringParams.Get("SortType") != null
                ? (VacancySearchSortType)Enum.Parse(typeof(VacancySearchSortType), queryStringParams.Get("SortType"))
                : VacancySearchSortType.Relevancy;

            searchModel.LocationType = queryStringParams.Get("LocationType") != null
                ? (ApprenticeshipLocationType)Enum.Parse(typeof(ApprenticeshipLocationType), queryStringParams.Get("LocationType"))
                : ApprenticeshipLocationType.NonNational;

            searchModel.Latitude       = queryStringParams.Get("Latitude").GetValueOrNull <double>();
            searchModel.Longitude      = queryStringParams.Get("Longitude").GetValueOrNull <double>();
            searchModel.WithinDistance = queryStringParams.Get("WithinDistance").GetValueOrDefault(5);
            searchModel.ResultsPerPage = queryStringParams.Get("ResultsPerPage").GetValueOrDefault(5);

            searchModel.Keywords            = queryStringParams.Get("Keywords");
            searchModel.Location            = queryStringParams.Get("Location");
            searchModel.ApprenticeshipLevel = queryStringParams.Get("ApprenticeshipLevel");
            searchModel.SearchField         = queryStringParams.Get("SearchField");
            searchModel.Category            = queryStringParams.Get("Category");
            searchModel.SubCategories       = queryStringParams.Get("SubCategories") != null?queryStringParams.Get("SubCategories").Split(',') : null;

            return(searchModel);
        }