/// <summary> /// Gets order statistics. Asynch call. /// </summary> /// <param name="callback">Callback function.</param> /// <param name="year"></param> public void GetOrderStatistics(Action <List <OrderStatistics> > callback, int year) { var context = new ActionDomainContext(); _orders = context.Orders; _callback = callback; context.Load(context.GetOrdersByYearQuery(year), GetOrdersByYearCallback, true); }
/// <summary> /// Constructor of AddToCart ViewModel. /// </summary> public AddToCartViewModel() { if (DesignerProperties.IsInDesignTool) { return; } _addtocartCommand = new RelayCommand(OnAddToCart); _addtocartCommand.IsEnabled = true; Context = new ActionDomainContext(); Products = Context.Products; }
/// <summary> /// Constructor for the OrderViewModel. /// </summary> public OrderViewModel() { if (DesignerProperties.IsInDesignTool) { return; } _filterCommand = new RelayCommand(OnFilter); _filterCommand.IsEnabled = true; _clearCommand = new RelayCommand(OnClearFilter); _clearCommand.IsEnabled = false; context = new ActionDomainContext(); // Associate EntitySets with Customer, Order, OrderDetail collections. Customers = context.Customers; Orders = context.Orders; OrderDetails = context.OrderDetails; LoadCustomers(); }
/// <summary> /// Constructor of Customer ViewModel /// </summary> public CustomerViewModel() { if (DesignerProperties.IsInDesignTool) { return; } // init commands. _addCommand = new RelayCommand(OnAdd); _editCommand = new RelayCommand(OnEdit); _deleteCommand = new RelayCommand(OnDelete); _saveCommand = new RelayCommand(OnSave); _cancelCommand = new RelayCommand(OnCancel); UpdateState(false); RaiseEvent(Loading); // Load customers from database context = new ActionDomainContext(); Customers = context.Customers; // important. context.Load(context.GetCustomersQuery(), GetCustomersQueryCallback, true); }