Ejemplo n.º 1
0
        public LocationInventoryListOptionModel GetLocationInventoryListOptionModel(int locationId)
        {
            var model = new LocationInventoryListOptionModel();

            model.SetDefaultOptions = () =>
            {
                model.LocationId = locationId;
                model.IsInStock  = true;
            };

            return(model);
        }
Ejemplo n.º 2
0
 public IList <LocationInventoryListModel> GetLocationInventoryListModels(LocationInventoryListOptionModel options)
 {
     using (var context = _contextFactory.CreateContext())
     {
         return(context.Inventory
                .AsNoTracking()
                .FilterBy(options)
                .OrderBy(i => i.Product.ProductCode)
                .ProjectBetween <Inventory, LocationInventoryListModel>()
                .ToList());
     }
 }
Ejemplo n.º 3
0
        public static IQueryable <Inventory> FilterBy(this IQueryable <Inventory> inventory, LocationInventoryListOptionModel options)
        {
            Expression <Func <Inventory, bool> > filter =
                i => (i.LocationId == options.LocationId) &&
                (options.IsAll || (options.IsInStock && i.StockQuantity > 0) || (options.IsReserved && i.ReservedQuantity > 0));

            //(options.IsAll ? true : (options.IsInStock ? i.StockQuantity > 0 : (options.IsReserved ? i.ReservedQuantity > 0 : false)));

            return(inventory.Where(filter));
        }