Beispiel #1
0
        public MediatorResponse <SavedSearchViewModel> RunSavedSearch(Guid candidateId, ApprenticeshipSearchViewModel apprenticeshipSearchViewModel)
        {
            Guid savedSearchId;

            var validSavedSearchId   = Guid.TryParse(apprenticeshipSearchViewModel.SavedSearchId, out savedSearchId);
            var savedSearchViewModel = validSavedSearchId
                ? _candidateServiceProvider.GetSavedSearch(candidateId, savedSearchId)
                : null;

            if (savedSearchViewModel == null)
            {
                return(GetMediatorResponse(
                           ApprenticeshipSearchMediatorCodes.SavedSearch.SavedSearchNotFound,
                           default(SavedSearchViewModel),
                           ApprenticeshipsSearchPageMessages.SavedSearchNotFound,
                           UserMessageLevel.Error));
            }

            if (savedSearchViewModel.HasError())
            {
                return(GetMediatorResponse(
                           ApprenticeshipSearchMediatorCodes.SavedSearch.RunSaveSearchFailed,
                           savedSearchViewModel,
                           ApprenticeshipsSearchPageMessages.RunSavedSearchFailed,
                           UserMessageLevel.Error));
            }

            return(GetMediatorResponse(ApprenticeshipSearchMediatorCodes.SavedSearch.Ok, savedSearchViewModel));
        }