Inheritance: BaseModel
コード例 #1
0
ファイル: ChartDataService.cs プロジェクト: rrawla/app-crm
        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;
        }
コード例 #2
0
        public CategoriesViewModel(Category category = null)
        {
            Category = category;

            SubCategories = new ObservableCollection<Category>();

            _DataClient = DependencyService.Get<IDataClient>();

        }
コード例 #3
0
        public CategoriesViewModel(Category category = null, bool isPerformingProductSelection = false)
        {
            Category = category;

            _IsPerformingProductSelection = isPerformingProductSelection;

            SubCategories = new ObservableCollection<Category>();

            _DataService = DependencyService.Get<IDataService>();

        }