public static IQueryable <StockItem> GetStockItems(this WideWorldImportersDbContext dbContext, int pageSize = 10, int pageNumber = 1, int?lastEditedBy = null, int?colorID = null, int?outerPackageID = null, int?supplierID = null, int?unitPackageID = null)
        {
            var query = dbContext.StockItems.AsQueryable();

            if (lastEditedBy.HasValue)
            {
                query = query.Where(item => item.LastEditedBy == lastEditedBy);
            }

            if (colorID.HasValue)
            {
                query = query.Where(item => item.ColorID == colorID);
            }

            if (outerPackageID.HasValue)
            {
                query = query.Where(item => item.OuterPackageID == outerPackageID);
            }

            if (supplierID.HasValue)
            {
                query = query.Where(item => item.SupplierID == supplierID);
            }

            if (unitPackageID.HasValue)
            {
                query = query.Where(item => item.UnitPackageID == unitPackageID);
            }

            return(query);
        }
Exemple #2
0
        public static IQueryable <StockItem> GetStockItems(this WideWorldImportersDbContext dbContext,
                                                           int pageSize     = 10, int pageNumber     = 1,
                                                           int?lastEditedBy = null, int?colorID      = null,
                                                           int?embalagemID  = null, int?fornecedorID = null, int?precoUnidade = null)
        {
            //Get quey do DbSet
            var query = dbContext.StockItems.AsQueryable();

            //Filtro do: 'LastEditedBy'
            if (lastEditedBy.HasValue)
            {
                query = query.Where(item => item.LastEditedBy == lastEditedBy);
            }

            //Filtro do: 'ColorID'
            if (colorID.HasValue)
            {
                query = query.Where(item => item.ColorID == colorID);
            }

            //Filtro do: 'OuterPackageID
            if (embalagemID.HasValue)
            {
                query = query.Where(item => item.EmbalagemID == embalagemID);
            }

            //Filtro do: 'SupplierID
            if (fornecedorID.HasValue)
            {
                query = query.Where(item => item.FornecedorID == fornecedorID);
            }

            //Filtro do: 'UnitPackageID'
            if (precoUnidade.HasValue)
            {
                query = query.Where(item => item.PrecoUnidade == precoUnidade);
            }

            return(query);
        }
Exemple #3
0
 public static async Task <StockItem> GetStockItemsByStockItemNameAsync(this WideWorldImportersDbContext dbContext, StockItem entity)
 => await dbContext.StockItems.FirstOrDefaultAsync(item => item.StockItemName == entity.StockItemName);
 public WarehouseRepository(WideWorldImportersDbContext dbContext)
     : base(dbContext)
 {
 }
 public Repository(WideWorldImportersDbContext dbContext)
 {
     DbContext = dbContext;
 }
        public static IQueryable <TEntity> Paging <TEntity>(this WideWorldImportersDbContext dbContext, int pageSize = 0, int pageNumber = 0) where TEntity : class
        {
            var query = dbContext.Set <TEntity>().AsQueryable();

            return(pageSize > 0 && pageNumber > 0 ? query.Skip((pageNumber - 1) * pageSize).Take(pageSize) : query);
        }
Exemple #7
0
 public UnitOfWork(WideWorldImportersDbContext dbContext)
 {
     this.Dbcontext = dbContext;
 }
Exemple #8
0
 public static IQueryable <Product> GetProducts(this WideWorldImportersDbContext dbContext)
 {
     return(dbContext.Products.AsQueryable());
 }
Exemple #9
0
 public static async Task <Product> GetProductByProductNameAsync(this WideWorldImportersDbContext dbContext, Product entity)
 => await dbContext.Products.FirstOrDefaultAsync(item => item.Name == entity.Name);