public async Task ExecuteLoadSeedDataCommand() { if (IsBusy) { return; } IsBusy = true; if (!_DataClient.IsSeeded) { await _DataClient.SeedLocalDataAsync(); } Orders = (await _DataClient.GetAllOrdersAsync()).ToObservableCollection(); WeeklySalesChartDataPoints = (await _ChartDataService.GetWeeklySalesDataPointsAsync(Orders)) .OrderBy(x => x.DateStart) .Select(x => new ChartDataPoint(x.DateStart.ToString("d MMM"), x.Amount)).ToObservableCollection(); WeeklySalesAverage = String.Format("{0:C}", WeeklySalesChartDataPoints.Average(x => x.YValue)); IsInitialized = true; IsBusy = false; }
public async Task ExecuteLoadSeedDataCommand(Account account) { if (IsBusy) { return; } IsBusy = true; if (!_DataClient.IsSeeded) { await _DataClient.SeedLocalDataAsync(); } Orders.Clear(); Orders.AddRange((await _DataClient.GetAllOrdersAsync()).Where(x => x.AccountId == account.Id)); WeeklySalesChartDataPoints.Clear(); WeeklySalesChartDataPoints.AddRange((await _ChartDataService.GetWeeklySalesDataPointsAsync(Orders)).OrderBy(x => x.DateStart).Select(x => new ChartDataPoint(FormatDateRange(x.DateStart, x.DateEnd), x.Amount))); var weeklyTotal = WeeklySalesChartDataPoints.Sum(x => x.YValue); CategorySalesChartDataPoints.Clear(); CategorySalesChartDataPoints.AddRange((await _ChartDataService.GetCategorySalesDataPointsAsync(Orders)).Select(x => new ChartDataPoint(x.Key, x.Sum(y => y.Amount))).OrderBy(x => x.XValue)); var categoriesTotal = CategorySalesChartDataPoints.Sum(x => x.YValue); WeeklySalesAverage = String.Format("{0:C}", WeeklySalesChartDataPoints.Average(x => x.YValue)); IsBusy = false; }
public async Task ExecuteLoadSeedDataCommand(Account account) { if (IsBusy) { return; } IsBusy = true; await _CustomerDataClient.SeedDataAsync(); Orders.Clear(); Orders.AddRange((await _CustomerDataClient.GetAllOrdersAsync()).Where(x => x.AccountId == account.Id)); WeeklySalesChartDataPoints.Clear(); WeeklySalesChartDataPoints.AddRange((await _ChartDataService.GetWeeklySalesDataPointsAsync(Orders)).OrderBy(x => x.DateStart).Select(x => new ChartDataPoint(x.DateStart.ToString("d MMM"), x.Amount))); CategorySalesChartDataPoints.Clear(); CategorySalesChartDataPoints.AddRange((await _ChartDataService.GetCategorySalesDataPointsAsync(Orders, _Account)).OrderBy(x => x.XValue)); WeeklySalesAverage = String.Format("{0:C}", WeeklySalesChartDataPoints.Average(x => x.YValue)); IsBusy = false; }