public async void Init(string searchParams)
        {
            _searchParams = JsonConvert.DeserializeObject<SearchParams>(searchParams);

            DataLoader.IsLoadingForTheFirstTime = true;
            await DataLoader.LoadItemsAsync(LoadItems);
        }
Ejemplo n.º 2
0
 public SearchParams(SearchParams copy)
 {
     SearchQuery = copy.SearchQuery;
     HasQuestion = copy.HasQuestion;
     HasAnswer = copy.HasAnswer;
     HasPassCriteria = copy.HasPassCriteria;
     HasComment = copy.HasComment;
     HasSourse = copy.HasSourse;
     HasAuthors = copy.HasAuthors;
     AllWords = copy.AllWords;
     AnyWord = copy.AnyWord;
     Limit = copy.Limit;
     Type = copy.Type;
     EndDate = copy.EndDate;
     StartDate = copy.StartDate;
     SearchAmongQuestions = copy.SearchAmongQuestions;
     SearchAmongTours = copy.SearchAmongTours;
     SearchAmongUnsorted = copy.SearchAmongUnsorted;
 }
Ejemplo n.º 3
0
 public bool Equals(SearchParams other)
 {
     if (ReferenceEquals(null, other))
         return false;
     if (ReferenceEquals(this, other))
         return true;
     return string.Equals(SearchQuery, other.SearchQuery)
         && string.Equals(Type, other.Type)
         && HasQuestion == other.HasQuestion
         && HasAnswer == other.HasAnswer
         && HasPassCriteria == other.HasPassCriteria
         && HasComment == other.HasComment
         && HasSourse == other.HasSourse
         && HasAuthors == other.HasAuthors
         && AnyWord == other.AnyWord
         && AllWords == other.AllWords
         && SearchAmongQuestions == other.SearchAmongQuestions
         && SearchAmongTours == other.SearchAmongTours
         && SearchAmongUnsorted == other.SearchAmongUnsorted
         && DateTime.Equals(StartDate, other.StartDate)
         && DateTime.Equals(EndDate, other.EndDate);
 }
Ejemplo n.º 4
0
        public async Task<List<ISearchQuestionsResult>> SearchQuestions(SearchParams searchParams, CancellationToken cancellationToken)
        {
            if (cashedSearch != null && cashedSearch.Item1.Equals(searchParams) && cashedSearch.Item1.Page >= searchParams.Page)
            {
				return cashedSearch.Item2;
            }

            PreLoad(cancellationToken);

            string url = "xml/search/questions/"
                    + Uri.EscapeUriString(searchParams.SearchQuery) + "/"
                    + (searchParams.AnyWord ? "any_word/" : "")
                    + searchParams.Type + "/"
                    + (searchParams.HasQuestion ? "Q" : "") + (searchParams.HasAnswer ? "A" : "") + (searchParams.HasPassCriteria ? "Z" : "") + (searchParams.HasComment ? "C" : "") + (searchParams.HasSourse ? "S" : "") + (searchParams.HasAuthors ? "U" : "") + "/"
                    + "from_" + searchParams.StartDate.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) + "/"
                    + "to_" + searchParams.EndDate.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) + "/"
                    + "limit" + searchParams.Limit
                    + "?page=" + searchParams.Page;
            
            var searchResults = await _simpleRestService.GetAsync<SearchResultsDto>(host, url,
                                    new XmlDeserializer<SearchResultsDto>(), cancellationToken);

            var questions = searchResults.questions.Select(dto => dto.ToModel()).ToList();

            if (cashedSearch != null && cashedSearch.Item1.Equals(searchParams))
            {
                cashedSearch.Item1.Page = searchParams.Page;
                cashedSearch.Item2.AddRange(questions);
                questions = cashedSearch.Item2;
            }
            else
            {
                cashedSearch = Tuple.Create<SearchParams, List<ISearchQuestionsResult>>(new SearchParams(searchParams), new List<ISearchQuestionsResult>(questions));
            }

            return questions;
        }
Ejemplo n.º 5
0
        public SearchParamsViewModel()
		{
            Title = StringResources.Search;

            SearchParams = new SearchParams();
		}