Esempio n. 1
0
        private string GetApprenticeshipLevel(bool reset)
        {
            if (reset)
            {
                UserDataProvider.Pop(CandidateDataItemNames.ApprenticeshipLevel);
            }

            return(UserDataProvider.Get(CandidateDataItemNames.ApprenticeshipLevel) ?? "All");
        }
        public MediatorResponse <SavedVacancyViewModel> DeleteSavedVacancy(Guid candidateId, int vacancyId)
        {
            var viewModel = _apprenticeshipApplicationProvider.DeleteSavedVacancy(candidateId, vacancyId);
            int savedVacancyCount;

            int.TryParse(UserDataProvider.Get(UserDataItemNames.SavedAndDraftCount), out savedVacancyCount);
            UserDataProvider.Push(UserDataItemNames.SavedAndDraftCount, Math.Max(0, savedVacancyCount - 1).ToString(CultureInfo.InvariantCulture));

            return(GetMediatorResponse(ApprenticeshipApplicationMediatorCodes.DeleteSavedVacancy.Ok, viewModel));
        }
Esempio n. 3
0
        /// <summary>
        /// Read from the BikeRentals.V_User view (selecting from the ASP NET Identity database)
        /// </summary>
        public User GetById(string id)
        {
            var res = UserDataProvider.Get(id, true);

            if (res == null)
            {
                throw new EntityNotFoundException(CallContext.ResourceUri, typeof(User), new[] { id }, LogLevel.Error);
            }

            return(res);
        }
Esempio n. 4
0
        public MediatorResponse <ApprenticeshipSearchViewModel> Index(Guid?candidateId, ApprenticeshipSearchMode searchMode, bool reset)
        {
            var lastSearchedLocation = UserDataProvider.Get(UserDataItemNames.LastSearchedLocation);

            if (string.IsNullOrWhiteSpace(lastSearchedLocation) && candidateId.HasValue)
            {
                var candidate = _candidateServiceProvider.GetCandidate(candidateId.Value);
                UserDataProvider.Push(UserDataItemNames.LastSearchedLocation, lastSearchedLocation = candidate.RegistrationDetails.Address.Postcode);
            }

            if (!candidateId.HasValue && searchMode == ApprenticeshipSearchMode.SavedSearches)
            {
                searchMode = ApprenticeshipSearchMode.Keyword;
            }

            var distances            = GetDistances(true);
            var sortTypes            = GetSortTypes();
            var resultsPerPage       = GetResultsPerPage();
            var apprenticeshipLevels = GetApprenticeshipLevels();
            var apprenticeshipLevel  = GetApprenticeshipLevel(reset);
            var searchFields         = GetSearchFields();
            var categories           = GetCategories();
            var savedSearches        = GetSavedSearches(candidateId);

            var viewModel = new ApprenticeshipSearchViewModel
            {
                WithinDistance       = 5,
                LocationType         = ApprenticeshipLocationType.NonNational,
                Location             = SplitSearchLocation(lastSearchedLocation, 0),
                Latitude             = SplitSearchLocation(lastSearchedLocation, 1).GetValueOrNull <double>(),
                Longitude            = SplitSearchLocation(lastSearchedLocation, 2).GetValueOrNull <double>(),
                Distances            = distances,
                SortTypes            = sortTypes,
                ResultsPerPage       = resultsPerPage,
                ApprenticeshipLevels = apprenticeshipLevels,
                ApprenticeshipLevel  = apprenticeshipLevel,
                SearchFields         = searchFields,
                Categories           = categories,
                SavedSearches        = savedSearches,
                SearchMode           = searchMode
            };

            return(GetMediatorResponse(ApprenticeshipSearchMediatorCodes.Index.Ok, viewModel));
        }
Esempio n. 5
0
        public MediatorResponse <TraineeshipSearchViewModel> Index(Guid?candidateId)
        {
            var lastSearchedLocation = UserDataProvider.Get(UserDataItemNames.LastSearchedLocation);

            if (string.IsNullOrWhiteSpace(lastSearchedLocation) && candidateId.HasValue)
            {
                var candidate = _candidateServiceProvider.GetCandidate(candidateId.Value);
                UserDataProvider.Push(UserDataItemNames.LastSearchedLocation, lastSearchedLocation = candidate.RegistrationDetails.Address.Postcode);
            }

            var traineeshipSearchViewModel = new TraineeshipSearchViewModel
            {
                WithinDistance = 40,
                Distances      = GetDistances(false),
                SortTypes      = GetSortTypes(),
                SortType       = VacancySearchSortType.Distance,
                ResultsPerPage = GetResultsPerPage(),
                Location       = SplitSearchLocation(lastSearchedLocation, 0),
                Latitude       = SplitSearchLocation(lastSearchedLocation, 1).GetValueOrNull <double>(),
                Longitude      = SplitSearchLocation(lastSearchedLocation, 2).GetValueOrNull <double>(),
            };

            return(GetMediatorResponse(TraineeshipSearchMediatorCodes.Index.Ok, traineeshipSearchViewModel));
        }
Esempio n. 6
0
 private string GetApprenticeshipLevel()
 {
     return(UserDataProvider.Get(CandidateDataItemNames.ApprenticeshipLevel) ?? "All");
 }
Esempio n. 7
0
 /// <summary>
 /// Read from the JoggingApp.V_User view (selecting from the ASP NET Identity database)
 /// </summary>
 public User Get(string id, bool throwExceptionIfNotFound)
 {
     return(UserDataProvider.Get(id, throwExceptionIfNotFound));
 }