//Methode om de data van de diefstallen en bikecontainers op te halen. public async Task LoadData() { vm = new BikeContainerViewModel(); theftVM = new BikeTheftViewModel(); await vm.GetHaltesAsync(); await theftVM.GetBikeTheftsAsync(); containers = vm.BikeContainers; thefts = theftVM.BikeThefts; }
public async Task <List <NeighbourhoodTheft> > GenerateNeighbourhoods() { //BikeTheftNeighbourhoodsModel btnm = new BikeTheftNeighbourhoodsModel(); BikeTheftViewModel bvm = new BikeTheftViewModel(); //List<Position> positions = new List<Position>(); await bvm.GetBikeTheftsAsync(); foreach (var neighbourhood in bvm.neighbourhoods) { NeighbourhoodTheft neighbourhoodTheft = new NeighbourhoodTheft(); neighbourhoodTheft.Name = neighbourhood; neighbourhoods.Add(neighbourhoodTheft); } foreach (BikeTheft bikeTheft in bvm.BikeThefts) { NeighbourhoodTheft neighbourhoodTheft = neighbourhoods.Find(x => x.Name.Contains(bikeTheft.Neighbourhood)); if (neighbourhoodTheft.Positions.Count == 0) { var possibleAddresses = await geoCoder.GetPositionsForAddressAsync(bikeTheft.City); foreach (var address in possibleAddresses) { neighbourhoodTheft.Positions.Add(address); } } if (neighbourhoodTheft.Positions.Count < 10) { //var possibleAddresses2 = await geoCoder.GetPositionsForAddressAsync(neighbourhoodTheft.Name + ", " + bikeTheft.Street); //foreach (var address in possibleAddresses2) //{ // neighbourhoodTheft.Positions.Add(address); //} } neighbourhoodTheft.AddNeighbourhood(bikeTheft.Neighbourhood); } return(neighbourhoods); }
public async Task <BikeColorsGraphModel> GenerateColors() { BikeColorsGraphModel bcgm = new BikeColorsGraphModel(); BikeTheftViewModel bvm = new BikeTheftViewModel(); await bvm.GetBikeTheftsAsync(); foreach (var color in bvm.colors) { Color colorObject = new Color(); colorObject.Name = color; colors.Add(colorObject); } foreach (BikeTheft bikeTheft in bvm.BikeThefts) { Color color = colors.Find(x => x.Name.Contains(bikeTheft.Color)); color.AddColor(bikeTheft.Color); } var filteredColors = colors.OrderByDescending(x => x.Count).Take(9); int Count = 0; foreach (Color color in filteredColors) { Count += color.Count; bcgm.AddData(color); } Color remainderColor = new Color(); remainderColor.Name = "Remainder colors"; for (int i = 0; i < bvm.BikeThefts.Count() - Count; i++) { remainderColor.AddColor("Reminder"); } bcgm.AddData(remainderColor); return(bcgm); }
public async Task <BikeBrandsGraphModel> GenerateBrands() { BikeBrandsGraphModel bbgm = new BikeBrandsGraphModel(); BikeTheftViewModel bvm = new BikeTheftViewModel(); await bvm.GetBikeTheftsAsync(); foreach (var brand in bvm.brands) { Brand brandObject = new Brand(); brandObject.Name = brand; brands.Add(brandObject); } foreach (BikeTheft bikeTheft in bvm.BikeThefts) { Brand brand = brands.Find(x => x.Name.Contains(bikeTheft.Brand)); brand.AddColor(bikeTheft.Brand); } var filteredBrands = brands.OrderByDescending(x => x.Count).Take(9); var Count = 0; foreach (Brand brand in filteredBrands) { Count += brand.Count; bbgm.AddData(brand); } Brand remainderBrand = new Brand(); remainderBrand.Name = "Remainder brand"; for (int i = 0; i < bvm.BikeThefts.Count() - Count; i++) { remainderBrand.AddColor("Reminder"); } bbgm.AddData(remainderBrand); return(bbgm); }