-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilterViewModel.cs
36 lines (25 loc) · 1.23 KB
/
FilterViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FilterCriteriaSample {
public class FilterViewModel {
public List<Category> Categories { get; private set; }
public decimal UnitPriceMinValue { get; private set; }
public decimal UnitPriceMaxValue { get; private set; }
public short UnitsOnOrderMinValue { get; private set; }
public short UnitsOnOrderMaxValue { get; private set; }
public short UnitsInStockMinValue { get; private set; }
public short UnitsInStockMaxValue { get; private set; }
public FilterViewModel(NwindDbContext context) {
Categories = context.Categories.ToList();
UnitPriceMinValue = context.Products.Min(p => p.UnitPrice).Value;
UnitPriceMaxValue = context.Products.Max(p => p.UnitPrice).Value;
UnitsInStockMinValue = context.Products.Min(p => p.UnitsInStock).Value;
UnitsInStockMaxValue = context.Products.Max(p => p.UnitsInStock).Value;
UnitsOnOrderMinValue = context.Products.Min(p => p.UnitsOnOrder).Value;
UnitsOnOrderMaxValue = context.Products.Max(p => p.UnitsOnOrder).Value;
}
}
}