async Task<double> GetOrderTotalForCategoryAsync(IEnumerable<Order> orders, Category category, int numberOfWeeks = 6, bool isOpen = false) { double total = 0; var categoryProducts = await _DataClient.GetAllChildProductsAsync(category.Id); DateTime dateEnd = DateTime.UtcNow; DateTime dateStart = dateEnd.AddDays(-numberOfWeeks * 7); IEnumerable<Order> results; if (isOpen) { results = orders.Where( order => order.IsOpen == isOpen && order.OrderDate >= dateStart && order.OrderDate <= dateEnd && categoryProducts.Any(product => product.Name.ToLower() == order.Item.ToLower())); } else { results = orders.Where( order => order.IsOpen == isOpen && order.ClosedDate >= dateStart && order.ClosedDate <= dateEnd && categoryProducts.Any(product => product.Name.ToLower() == order.Item.ToLower())); } foreach (var order in results) { total += order.Price; } return total; }
public CategoriesViewModel(Category category = null) { Category = category; SubCategories = new ObservableCollection<Category>(); _DataClient = DependencyService.Get<IDataClient>(); }
public CategoriesViewModel(Category category = null, bool isPerformingProductSelection = false) { Category = category; _IsPerformingProductSelection = isPerformingProductSelection; SubCategories = new ObservableCollection<Category>(); _DataService = DependencyService.Get<IDataService>(); }