public async Task <ChartViewModel> CreateAsync() { var data = await _parkRepository.GetAllSportsClubsAsync(); var parks = await _parkRepository.GetAllParksAsync(false); var count = new decimal[parks.Length]; foreach (var d in data) { count[Array.FindIndex(parks, p => p.ParkId == d.Park.ParkId)] += d.Members; } var builder = new ChartBuilder(ChartType.scatter) .AddScatterData(parks.Select(p => (decimal)p.SizeInMetresSquared).ToArray(), count, 7, 0, 0, "Members by park area" ) .AddBackgroundColors() .AddBorderColors() .AddXAxesSet("Park size (metres squared)") .AddYAxesSet("Total club members") .SetTitle("Total Club Members by Park area") .SetDuration(2) .SetMaintainAspectRatio(true, true); var chart = builder.GetChart(); return(new ChartViewModel(chart)); }
public async Task <ChartViewModel> CreateAsync() { var results = await _parkRepository.GetAllSportsClubsAsync(); var sports = (await _parkRepository.GetAllSportTypesAsync()).Select(x => x.Name).ToArray(); var count = new decimal[sports.Length]; foreach (var result in results) { count[Array.FindIndex(sports, s => s.Equals(result.Sport.ToString()))]++; } var builder = new ChartBuilder(ChartType.doughnut) .AddDataX(sports) .AddDatasetY(count, label: "Make up of sports offered by our clubs", borderWidth: 1, dp: 0 ) .AddBackgroundColors() .SetTitle("Sports of all of our clubs") .SetDuration(5) .SetMaintainAspectRatio(true, true); var chart = builder.GetChart(); return(new ChartViewModel(chart)); }
public async Task <SportsClub[]> GetAllSportsClubs() { return(await _parkRepository.GetAllSportsClubsAsync()); }
public async Task <SportsClubModel[]> GetAllSportsClubModelsAsync() { var results = _mapper.Map <SportsClubModel[]>(await _parkRepository.GetAllSportsClubsAsync()); return(results); }