public IHttpActionResult SearchByDate(DateSearchRequestDto dto)
        {
            ISearchingCriterion <Offer> criterion =
                OffersSearchingCriteriaFactory.CreateDateSearchingCriterion(dto.MinimalDate, dto.MaximalDate,
                                                                            dto.ShowPartiallyMatchingResults);

            return(Search(dto.Username, new[] { criterion }, dto.SortType, dto.SortBy));
        }
Example #2
0
        public async Task <IEnumerable <Offer> > SearchByDateAsync(string username, DateTime?minimalDate, DateTime?maximalDate,
                                                                   bool showPartiallyMatchingResults, SortType sortType, SortBy sortBy)
        {
            DateSearchRequestDto dto = new DateSearchRequestDto()
            {
                Username    = username,
                MinimalDate = minimalDate,
                MaximalDate = maximalDate,
                ShowPartiallyMatchingResults = showPartiallyMatchingResults,
                SortType = sortType,
                SortBy   = sortBy
            };
            var res = await Post <DateSearchRequestDto, SearchResultDto>("date", dto);

            return(res.Offers);
        }
        public void SearchByDateTest2()
        {
            DateSearchRequestDto dto = new DateSearchRequestDto()
            {
                MinimalDate = new DateTime(2015, 12, 20),
                MaximalDate = new DateTime(2015, 12, 22),
                SortBy      = SortBy.Price,
                SortType    = SortType.Ascending,
                Username    = "******"
            };

            IHttpActionResult result = _controller.SearchByDate(dto);
            var contentResult        = result as OkNegotiatedContentResult <SearchResultDto>;

            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(0, contentResult.Content.Offers.Count());
        }