public async Task <TileRecord> GetTotalConfirmedCase() { var confirmedTotalCases = await HistoryOfCasesService.GetCummilativeCases(); return(new TileRecord { Value = confirmedTotalCases.Where(x => x.District == District.State).Max(x => x.Count), Title = "Total Confirmed Cases" }); }
private async Task <List <GraphRecord> > GetDistrictWiseDistribution() { var casesRecorded = await HistoryOfCasesService.GetCummilativeCases(); return(casesRecorded.Where(x => x.District != District.State) .GroupBy(x => x.District) .Select(x => new GraphRecord { Date = x.Max(c => c.Date), Key = x.Key.ToString(), Value = x.OrderByDescending(c => c.Date).First().Count }) .ToList()); }
private async Task <List <GraphRecord> > GetNumberOfDaysForMajorMilestonesAsync() { var historicalCasesCummilative = (await HistoryOfCasesService.GetCummilativeCases()).Where(x => x.District == District.State).OrderBy(x => x.Date); var numberTillFifty = historicalCasesCummilative.TakeWhile(x => x.Count <= 50); var numberFromFiftyToHundred = historicalCasesCummilative.Skip(numberTillFifty.Count()).TakeWhile(x => x.Count <= 100); var numberFromHundredToTwoHundred = historicalCasesCummilative.Skip(numberFromFiftyToHundred.Count()).TakeWhile(x => x.Count <= 200); var numberFromTwoHundredToThreeHundred = historicalCasesCummilative.Skip(numberFromHundredToTwoHundred.Count()).TakeWhile(x => x.Count <= 300); var numberFromThreeHundredToFourHundred = historicalCasesCummilative.Skip(numberFromTwoHundredToThreeHundred.Count()).TakeWhile(x => x.Count <= 400); var numberFromFourHundredToFiveHundred = historicalCasesCummilative.Skip(numberFromThreeHundredToFourHundred.Count()).TakeWhile(x => x.Count <= 500); var result = new List <GraphRecord>(); result.Add(new GraphRecord { Date = numberFromFiftyToHundred.Last().Date, Key = "50-100", Value = numberFromFiftyToHundred.Count() }); result.Add(new GraphRecord { Date = numberFromHundredToTwoHundred.Last().Date, Key = "100-200", Value = numberFromHundredToTwoHundred.Count() }); result.Add(new GraphRecord { Date = numberFromTwoHundredToThreeHundred.Last().Date, Key = "200-300", Value = numberFromTwoHundredToThreeHundred.Count() }); result.Add(new GraphRecord { Date = numberFromThreeHundredToFourHundred.Last().Date, Key = "300-400", Value = numberFromThreeHundredToFourHundred.Count() }); result.Add(new GraphRecord { Date = numberFromFourHundredToFiveHundred.Last().Date, Key = "400-500", Value = numberFromFourHundredToFiveHundred.Count() }); return(result); }
public async Task <TileRecord> GetRecoveryRate() { var activeCasesCummilative = await ActiveCaseService.GetCummilativeCases(); var historicalCasesCummilative = await HistoryOfCasesService.GetCummilativeCases(); var fatalCaseCummilative = await FatalCaseService.GetCummilativeCases(); var totalConfirmedCases = historicalCasesCummilative.Where(x => x.District == District.State).OrderBy(x => x.Date).Last().Count; var totalActiveCases = activeCasesCummilative.Where(x => x.District == District.State).OrderBy(x => x.Date).Last().Count; var totalFatalCases = fatalCaseCummilative.Where(x => x.District == District.State).Max(x => x.Count); return(new TileRecord { Title = "Recovery %", Value = Math.Round(((double)(totalConfirmedCases - (totalFatalCases + totalActiveCases)) / (double)totalConfirmedCases) * 100, 2) }); }
private async Task <List <GraphRecord> > GetStateWideCummilativeCasesAsync() { var casesRecorded = await HistoryOfCasesService.GetCummilativeCases(); return(casesRecorded.Where(x => x.District == District.State).CastAsGraphRecord().ToList()); }