Esempio n. 1
0
 public IList <SalesOrderListModel> GetSalesOrderListModels(SalesOrderListOptionsModel options)
 {
     using (var context = _contextFactory.CreateContext())
     {
         return(context.SalesOrders
                .AsNoTracking()
                .FilterBy(options)
                .OrderByDescending(s => s.OrderNo)
                .ProjectBetween <SalesOrder, SalesOrderListModel>()
                .ToList());
     }
 }
Esempio n. 2
0
        public static IQueryable <SalesOrder> FilterBy(this IQueryable <SalesOrder> salesOrders, SalesOrderListOptionsModel options)
        {
            Expression <Func <SalesOrder, bool> > filter =
                so => (String.IsNullOrWhiteSpace(options.OrderNo) || so.OrderNo.ToLower().StartsWith(options.OrderNo.ToLower())) &&
                (String.IsNullOrWhiteSpace(options.CompanyName) || so.Company.Name.ToLower().Contains(options.CompanyName.ToLower())) &&
                (String.IsNullOrWhiteSpace(options.ShippingAddressDescription) || so.ShippingAddress.Description.ToLower().Contains(options.ShippingAddressDescription.ToLower())) &&
                (options.CompanyCountryId == null || so.Company.Addresses.Any(a => a.CountryId == options.CompanyCountryId && a.IsBilling)) &&
                (options.IsClosed == null || so.IsClosed == options.IsClosed);

            return(salesOrders.Where(filter));
        }
Esempio n. 3
0
 private void InitializeOptionsModel()
 {
     OptionsModel = _service.GetSalesOrderListOptionsModel();
     OptionsModel.DefaultSetup();
     OptionsModel.OptionChanged += ClearItems;
 }