async void ExecuteLoadCategoriesCommand() { if (IsBusy) { return; } IsBusy = true; LoadCategoriesCommand.ChangeCanExecute(); SubCategories = new ObservableCollection <Category>((await _DataClient.GetCategoriesAsync((_Category != null) ? _Category.Id : null))); IsBusy = false; LoadCategoriesCommand.ChangeCanExecute(); }
public async Task <List <ChartDataPoint> > GetCategorySalesDataPointsAsync(IEnumerable <Order> orders, Account account = null, int numberOfWeeks = 6, bool isOpen = false) { // get top-level categories by passing no parent categoryId var categories = await _DataClient.GetCategoriesAsync(); List <ChartDataPoint> categorySalesDataPoints = new List <ChartDataPoint>(); orders = (account == null) ? orders : orders.Where(order => order.AccountId == account.Id); foreach (var category in categories) { double amount = await GetOrderTotalForCategoryAsync(orders, category, numberOfWeeks, isOpen); categorySalesDataPoints.Add(new ChartDataPoint(category.Name, amount)); } return(categorySalesDataPoints); }