Exemplo n.º 1
0
        public List <ProductCategoryViewModel> Search(ProductCategorySearchModel searchModel)
        {
            var query = _context.ProductCategories.Select(x => new ProductCategoryViewModel
            {
                Id           = x.Id,
                Picture      = x.Picture,
                Name         = x.Name,
                CreationDate = x.CreationDate.ToFarsi()
            });

            if (!string.IsNullOrWhiteSpace(searchModel.Name))
            {
                query = query.Where(x => x.Name == searchModel.Name);
            }
            return(query.OrderByDescending(x => x.Id).ToList());
        }
        public List <ProductCategoryViewModel> Search(ProductCategorySearchModel searchModel)
        {
            var query = _db.ProductCategories.Include(c => c.Products).Select(p => new ProductCategoryViewModel
            {
                Name          = p.Name,
                Id            = p.Id,
                CreationDate  = p.CreationDate.ToPersianDate(),
                Picture       = p.Picture,
                ProductsCount = p.Products.Count
            });

            if (!string.IsNullOrWhiteSpace(searchModel.Name))
            {
                query = query.Where(c => c.Name.Contains(searchModel.Name));
            }

            return(query.OrderByDescending(p => p.Id).AsNoTracking().ToList());
        }
Exemplo n.º 3
0
        public List <ProductCategoryViewModel> Search(ProductCategorySearchModel searchModel)
        {
            var query = _context.ProductCategories.Select(c => new ProductCategoryViewModel()
            {
                Id             = c.Id,
                Name           = c.Name,
                CreationDate   = c.CreationDate.ToFarsi(),
                picture        = c.picture,
                ProductCount   = c.Products.Count(),
                ShowInMainPage = c.ShowinMainPage,
            });

            if (!string.IsNullOrWhiteSpace(searchModel.Name))
            {
                query = query.Where(c => c.Name.Contains(searchModel.Name));
            }

            return(query.OrderByDescending(c => c.Id).ToList());
        }
 public List <ProductCategoryViewModel> Search(ProductCategorySearchModel searchModel)
 {
     return(_productCategoryRepository.Search(searchModel));
 }
Exemplo n.º 5
0
 public void OnGet(ProductCategorySearchModel searchModel)
 {
     ProductCategories = _productCategoryApplication.Search(searchModel);
 }
 public List <ProductCategoryViewModel> Search(ProductCategorySearchModel searchModel)
 {
     return(repo.Search(searchModel));
 }