示例#1
0
        public List <ProductEntity> Get(EmployeeEntity EmployeeEntity, ProductSearchEntity ProductSearchEntity)
        {
            if (ProductSearchEntity == null)
            {
                ProductSearchEntity = new ProductSearchEntity();
            }

            List <Product> Products = UnitOfWork.ProductRepository.List(ProductSearchEntity);

            return(Products.ToList().Select(p => new ProductEntity(p, p.Category, p.Category.ProductAttributes, p.Discounts, p.Packs, p.ProductPictures, p.ProductValues)).ToList());
        }
示例#2
0
        public int Count(ProductSearchEntity ProductSearchEntity)
        {
            if (ProductSearchEntity == null)
            {
                ProductSearchEntity = new ProductSearchEntity();
            }
            IQueryable <Product> Products = context.Products;

            Apply(Products, ProductSearchEntity);
            return(Products.Count());
        }
示例#3
0
        public List <Product> List(ProductSearchEntity ProductSearchEntity)
        {
            if (ProductSearchEntity == null)
            {
                ProductSearchEntity = new ProductSearchEntity();
            }
            IQueryable <Product> Products = context.Products
                                            .Include(p => p.Category).ThenInclude(c => c.ProductAttributes)
                                            .Include(p => p.Discounts)
                                            .Include(p => p.Packs)
                                            .Include(p => p.ProductPictures)
                                            .Include(p => p.ProductValues);;

            Apply(Products, ProductSearchEntity);
            SkipAndTake(Products, ProductSearchEntity);
            return(Products.ToList());
        }
示例#4
0
 private IQueryable <Product> Apply(IQueryable <Product> Products, ProductSearchEntity ProductSearchEntity)
 {
     if (ProductSearchEntity.Id.HasValue)
     {
         Products = Products.Where(wh => wh.Id == ProductSearchEntity.Id.Value);
     }
     if (ProductSearchEntity.CategoryId.HasValue)
     {
         Products = Products.Where(wh => wh.CategoryId == ProductSearchEntity.CategoryId.Value);
     }
     if (ProductSearchEntity.ManufacturerId.HasValue)
     {
         Products = Products.Where(wh => wh.ManufacturerId == ProductSearchEntity.ManufacturerId.Value);
     }
     if (!string.IsNullOrEmpty(ProductSearchEntity.Code))
     {
         Products = Products.Where(wh => wh.Code.ToLower().Contains(ProductSearchEntity.Code.ToLower()));
     }
     if (!string.IsNullOrEmpty(ProductSearchEntity.Unit))
     {
         Products = Products.Where(wh => wh.Unit.ToLower().Contains(ProductSearchEntity.Unit.ToLower()));
     }
     return(Products);
 }
示例#5
0
 public List <ProductEntity> Get(ProductSearchEntity SearchProductEntity)
 {
     return(ProductService.Get(EmployeeEntity, SearchProductEntity));
 }
示例#6
0
 public long Count(ProductSearchEntity SearchProductEntity)
 {
     return(ProductService.Count(EmployeeEntity, SearchProductEntity));
 }
示例#7
0
 public int Count(EmployeeEntity EmployeeEntity, ProductSearchEntity ProductSearchEntity)
 {
     return(UnitOfWork.ProductRepository.Count(ProductSearchEntity));
 }