Esempio n. 1
0
        public MediatorResponse <ApprenticeshipSearchViewModel> SaveSearch(Guid candidateId, ApprenticeshipSearchViewModel viewModel)
        {
            viewModel.Categories = GetCategories();

            if (!viewModel.Longitude.HasValue || !viewModel.Latitude.HasValue)
            {
                //todo: should we fail to save the search if we don't have a location?
                //todo: or we could try work out the geo location from the location name, that way we can filter
                //todo: searches without geo loctions from any saved search emailing?
            }

            viewModel = _candidateServiceProvider.CreateSavedSearch(candidateId, viewModel);

            if (viewModel.HasError())
            {
                return(GetMediatorResponse(ApprenticeshipSearchMediatorCodes.SaveSearch.HasError, viewModel, viewModel.ViewModelMessage, UserMessageLevel.Error));
            }

            return(GetMediatorResponse(ApprenticeshipSearchMediatorCodes.SaveSearch.Ok, viewModel, VacancySearchResultsPageMessages.SaveSearchSuccess, UserMessageLevel.Success));
        }