Ejemplo n.º 1
0
        public async Task Order_Test()
        {
            for (var i = 0; i <= (int)SortBy.DistinctName; i++)
            {
                var query = repository.FilterLots((SortBy)i, ShowOptions.Active, 0);
                var lots  = (await repository.FindRange(query, 20, 0)).ToList();

                var expected = SelectLots((SortBy)i, Lots);

                Assert.Equal(expected[0].Id, lots[0].Id);
                Assert.Equal(expected.Last().Id, lots.Last().Id);
                Assert.Equal(expected.Count, lots.Count);
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> LoadLots(string search, int categoryId, SortBy sortBy, ShowOptions show, int take, int skip)
        {
            var query = _repository.FilterLots(sortBy, show, categoryId);

            if (show == ShowOptions.MyLots)
            {
                query = HttpContext.User.Identity.IsAuthenticated
                    ? query.Where(i => i.AppUserId == HttpContext.UserId())
                    : query.Where(i => i.IsAvailable);
            }

            if (!string.IsNullOrEmpty(search))
            {
                query = search[0] == '@'
                    ? query.Where(i => i.AppUser.UserName.Contains(search.Substring(1)))
                    : query.Where(i => i.Title.Contains(search));
            }

            var lots = await _repository.FindRange(query, take, skip, this.GetTimezoneOffset());

            // var lots = await _repository.FindRange(query, take, skip);

            var categories = await _categoryRepository.GetAll();

            ViewBag.Categories = categories.ToDictionary(k => k.Id, v => v.Name);

            return(PartialView("_LotList", lots));
        }