public LocationInventoryListOptionModel GetLocationInventoryListOptionModel(int locationId) { var model = new LocationInventoryListOptionModel(); model.SetDefaultOptions = () => { model.LocationId = locationId; model.IsInStock = true; }; return(model); }
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()); } }
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)); }