public async void UpdataCampainTaskTypeAsync(CampainTaskType type) { if (campainFilter != type) { campainFilter = type; await campainTaskCollection.FilterAsync(FilterByCampainTaskType); } }
public async Task <List <ProductItem> > GetProductItemListAsync(CategoryType filter) #endif { categoryFilter = filter; #if !XF #if WINDOWS_UWP productCollection.Filter = null; #endif productCollection.Filter = new Predicate <object>(FilterByCategoryType); #else await productCollection.FilterAsync(FilterByCategoryType); #endif List <ProductItem> list = new List <ProductItem>(); foreach (Product product in productCollection) { ProductItem item = new ProductItem(product); list.Add(item); } return(list); }
public async Task UpdataDataByDateRangeAsync() #endif { #if !XF saleCollection.Filter = new Predicate <object>(FilterByDateRange); saleCollection.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending)); budgetCollection.Filter = new Predicate <object>(FilterByDateRange); opportunityCollection.Filter = new Predicate <object>(FilterByDateRange); regionWiseSaleCollection.Filter = new Predicate <object>(FilterByDateRange); regionSaleGoalCollection.Filter = new Predicate <object>(FilterByDateRange); #else await saleCollection.FilterAsync(FilterByDateRange); await saleCollection.SortAsync("Date"); await budgetCollection.FilterAsync(FilterByDateRange); await opportunityCollection.FilterAsync(FilterByDateRange); await regionWiseSaleCollection.FilterAsync(FilterByDateRange); await regionSaleGoalCollection.FilterAsync(FilterByDateRange); #endif opportunityList = new List <Opportunity>(); foreach (OpportunityLevel value in Enum.GetValues(typeof(OpportunityLevel))) { opportunityList.Add(new Opportunity { Level = value, Sales = 0 }); } var campainTaskItems = new List <CampainTaskItem>(); var productSaleMap = new Dictionary <int, SaleItem>(); var customerSaleMap = new Dictionary <int, SaleItem>(); foreach (Sale sale in saleCollection) { var profit = DataService.GetService().FindProfitFormCurrentSale(sale); if (sale.Campaign.Name != "None") { campainTaskItems.Add(new CampainTaskItem(sale)); } if (customerSaleMap.ContainsKey(sale.CustomerId)) { customerSaleMap[sale.CustomerId].Sales += sale.Summ; customerSaleMap[sale.CustomerId].Profit += profit; } else { customerSaleMap.Add(sale.CustomerId, new SaleItem { Id = sale.CustomerId, Sales = sale.Summ, Profit = profit, Name = sale.Customer.ToString(), Date = sale.Date }); } if (productSaleMap.ContainsKey(sale.ProductId)) { productSaleMap[sale.ProductId].Sales += sale.Summ; productSaleMap[sale.ProductId].Profit += profit; } else { productSaleMap.Add(sale.ProductId, new SaleItem { Id = sale.ProductId, Sales = sale.Summ, Profit = profit, Name = sale.Product.ToString(), Date = sale.Date }); } } var regionSaleMap = new Dictionary <int, SaleGoalItem>(); var categorySaleMap = new Dictionary <int, SaleGoalItem>(); foreach (BudgetItem budget in budgetCollection) { if (categorySaleMap.ContainsKey(budget.CategoryId)) { categorySaleMap[budget.CategoryId].Sales += budget.Sales; categorySaleMap[budget.CategoryId].Profit += budget.Profit; categorySaleMap[budget.CategoryId].Goal += budget.Goal; } else { SaleGoalItem item = new SaleGoalItem(); item.Name = budget.Category.ToString(); item.Goal = budget.Goal; item.Sales = budget.Sales; item.Profit = budget.Profit; categorySaleMap.Add(budget.CategoryId, item); } } foreach (RegionSalesGoal region in regionSaleGoalCollection) { if (regionSaleMap.ContainsKey(region.RegionId)) { regionSaleMap[region.RegionId].Sales += region.Sales; regionSaleMap[region.RegionId].Profit += region.Profit; regionSaleMap[region.RegionId].Goal += region.Goal; } else { SaleGoalItem item = new SaleGoalItem(); item.Name = region.Region.ToString(); item.Goal = region.Goal; item.Sales = region.Sales; item.Profit = region.Profit; regionSaleMap.Add(region.RegionId, item); } } #if !XF campainTaskCollection = new ListCollectionView(campainTaskItems); campainTaskCollection.Filter = new Predicate <object>(FilterByCampainTaskType); productSaleCollection = new ListCollectionView(productSaleMap.Values.ToList()); productSaleCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending)); customerSaleCollection = new ListCollectionView(customerSaleMap.Values.ToList()); customerSaleCollection.SortDescriptions.Add(new SortDescription("Sales", ListSortDirection.Descending)); #else campainTaskCollection = new C1CollectionView <CampainTaskItem>(campainTaskItems); await campainTaskCollection.FilterAsync(FilterByCampainTaskType); productSaleCollection = new C1CollectionView <SaleItem>(productSaleMap.Values.ToList()); await productSaleCollection.SortAsync("Sales", SortDirection.Descending); customerSaleCollection = new C1CollectionView <SaleItem>(customerSaleMap.Values.ToList()); await customerSaleCollection.SortAsync("Sales", SortDirection.Descending); #endif regionSalesVsGoal = regionSaleMap.Values.ToList(); categorySalesVsGoal = categorySaleMap.Values.ToList(); foreach (OpportunityItem opportunity in opportunityCollection) { OpportunityItemList[opportunity.LevelId].Sales += opportunity.Sales; } }