Пример #1
0
        public Task <List <ShopViewModel> > GetVendorShops(SearchShops searchShops)
        {
            List <ShopViewModel> shopViews = new List <ShopViewModel>();
            List <Shop>          shopIds   = new List <Shop>();
            int totalSkip = searchShops.PageSize * (searchShops.PageNumber - 1);

            if (!string.IsNullOrEmpty(searchShops.ShopId))
            {
                shopIds = _context.Shops.Where(x => x.Id == searchShops.ShopId).Skip(totalSkip).Take(searchShops.PageSize).ToList();
            }
            else if (!string.IsNullOrEmpty(searchShops.City) && searchShops.CategoryId != "null")
            {
                shopIds = _context.Shops.Where(x => x.City.ToLower().Contains(searchShops.City.ToLower()) && x.CategoryIds.Contains(searchShops.CategoryId)).Skip(totalSkip).Take(searchShops.PageSize).Distinct().ToList();
            }
            else if (!string.IsNullOrEmpty(searchShops.City))
            {
                shopIds = _context.Shops.Where(x => x.City.ToLower().Contains(searchShops.City.ToLower())).Skip(totalSkip).Take(searchShops.PageSize).Distinct().ToList();
            }
            else if (searchShops.CategoryId != null && searchShops.CategoryId != "null")
            {
                shopIds = _context.Shops.Where(x => x.CategoryIds.Contains(searchShops.CategoryId)).Skip(totalSkip).Take(searchShops.PageSize).Distinct().ToList();
            }
            else
            {
                shopIds = _context.Shops.Skip(totalSkip).Take(searchShops.PageSize).Distinct().ToList();
            }
            shopViews = _mapper.Map <List <ShopViewModel> >(shopIds);
            return(Task.FromResult(shopViews));
        }
Пример #2
0
        public async Task <ActionResult <IEnumerable <ShopViewModel> > > GetVendorShops(SearchShops searchShops)
        {
            var result = await _singleton.vendorRepository.GetVendorShops(searchShops);

            return(result);
        }