private IEnumerable<ResponseSet> FilterResponseSet(FilterParameters parameters, IEnumerable<ResponseSet> responseSets, Func<ResponseSet, DateTime> criteriaDate)
 {
     var resultCollection = new List<ResponseSet>();
     switch (parameters.Type)
     {
         case FilterType.ByDate:
             {
                 switch (parameters.Date.SelectedPeriod.Key)
                 {
                     case TimePeriods.After:
                         resultCollection = responseSets.Where(r => criteriaDate(r).Date > parameters.Date.SelectedDate.Date).ToList();
                         break;
                     case TimePeriods.At:
                         resultCollection = responseSets.Where(r => criteriaDate(r).Date == parameters.Date.SelectedDate.Date).ToList();
                         break;
                     case TimePeriods.Before:
                         resultCollection = responseSets.Where(r => criteriaDate(r).Date < parameters.Date.SelectedDate.Date).ToList();
                         break; 
                     case TimePeriods.Between:
                         resultCollection = responseSets.Where(r => criteriaDate(r).Date <= parameters.Date.SelectedEndDate.Date && criteriaDate(r).Date >= parameters.Date.SelectedStartDate.Date).ToList();
                         break;
                 };
             }
             break;
     }
     return resultCollection;
 }
 private void InitializeViewModelExecute()
 {
     this._filterProcessor = new FilterProcessor();
     this.savedSearchHelper.StartSearch();
     this.submittedSearchHelper.StartSearch();
     this.currentParameters = new FilterParameters();
     this.SearchInSavedString = string.Empty;
     this.SearchInSubmittedString = string.Empty;
    
     if (NavigationProvider.NavigationParameters.ContainsKey(Constants.FILTER_KEY))
     {
         this.currentParameters = (FilterParameters)NavigationProvider.NavigationParameters[Constants.FILTER_KEY];
         NavigationProvider.NavigationParameters.Remove(Constants.FILTER_KEY);
         this.SavedResponses = new ObservableCollection<ResponseSet>(_filterProcessor.FilterSavedResponseSet(currentParameters));
         this.filteredSavedResults = this.SavedResponses;
         this.SubmittedResponses = new ObservableCollection<ResponseSet>(_filterProcessor.FilterSubmittedResponseSet(currentParameters));
         this.filteredSubmittedResults = this.SubmittedResponses;
     }
 }
 public IEnumerable<ResponseSet> FilterSubmittedResponseSet(FilterParameters parameters)
 {
     return FilterResponseSet(parameters, _responseSetRepository.GetSubmittedResponseSetsForUser(Membership.CurrentUser.ID), c => { return c.DateSubmitted.Value; });
 }
        private void NavigateToFilterResultExecute()
        {
            FilterParameters parameters = new FilterParameters();

            switch (Locator.FilterResponsesStatic.CurrentFilter)
            {
                case FilterPages.FilterByDate:
                    parameters.Type = FilterType.ByDate;
                    parameters.Date = new DateParameters()
                    {
                        SelectedDate = Locator.FilterResponsesStatic.SelectedDate,
                        SelectedStartDate = Locator.FilterResponsesStatic.SelectedStartDate,
                        SelectedEndDate = Locator.FilterResponsesStatic.SelectedEndDate,
                        SelectedPeriod = Locator.FilterResponsesStatic.SelectedPeriod
                    };
                    break;
                case FilterPages.FilterByLocation:
                    if (Locator.FilterResponsesStatic.IsFilterByGps)
                    {
                        parameters.Type = FilterType.ByGps;
                    }
                    else
                    {
                        parameters.Type = FilterType.ByAddress;
                        parameters.Address = new AddressParameters()
                        {
                            City = Locator.FilterResponsesStatic.City,
                            State = Locator.FilterResponsesStatic.State,
                            StreetAddress = Locator.FilterResponsesStatic.StreetAddress
                        };
                    }
                    break;
            }

            NavigationProvider.NavigationParameters.Add(Constants.FILTER_KEY, parameters);
            NavigationProvider.Navigate(new Uri(Constants.FILER_RESULT_PAGE_SOURCE, UriKind.Relative));
        }