internal static List <ReturnData> FillRangeData(DateTime dateFrom, DateTime dateTo, int top, Func <RegionData, float> func) { return(dateFrom.Date == dateTo.Date ? DataReaderRegion .ReadRegionsAtDate(dateFrom) .Select((curr) => new ReturnData() { data = curr.data, value = func.Invoke(curr), lbl = curr.denominazione_regione }) .OrderByDescending(v => v.value) .Take(top) .ToList() : DataReaderRegion .ReadRegionsAtRangeDate(dateFrom, dateTo) .GroupBy(g => g.codice_regione) .Select((curr) => new ReturnData() { data = curr.Max(r => r.data), value = curr.Sum(r => func.Invoke(r)), lbl = curr.Max(r => r.denominazione_regione) }) .OrderByDescending(v => v.value) .Take(top) .ToList()); }
public static List <ReturnData> FillRegionWithFunction(int region, Func <RegionData, float> func) { return(DataReaderRegion.ReadRegionData(region) .Select((curr, i) => new ReturnData() { data = curr.data, value = func?.Invoke(curr) ?? 0F, lbl = curr.data.ToString("dd/MM/yy") } ) .ToList()); }
internal static Dictionary <int, List <ReturnData> > FillRangeDataDiff(DateTime dateFrom, DateTime dateTo, int top, Func <RegionData, float> func) { var list = dateFrom.Date == dateTo.Date ? DataReaderRegion .ReadRegionsAtDate(dateFrom) .ToList() : DataReaderRegion .ReadRegionsAtRangeDate(dateFrom, dateTo) .ToList(); return(null); //return list.Aggregate(new Dictionary<List<int>, ReturnData>(), (acc, v) => { acc.Add(v.codice_regione, new ReturnData() { data = v.data, value = func.Invoke(v), lbl = v.data.ToString("dd/MM/yy") }); return acc; }); }
internal static List <ReturnData> FillTotalyCases(int region) { return(DataReaderRegion.ReadRegionData(region) .OrderBy(d => d.data) .Select((s) => new ReturnData { data = s.data, lbl = s.data.ToString("dd/MM/yy"), value = s.totale_casi } ) .ToList()); }
internal static List <ReturnData> FillTotalRegionCasesAtDate(DateTime date, int top) { return(DataReaderRegion .ReadRegionsAtDate(date) .Select((curr) => new ReturnData() { data = curr.data, value = curr.totale_positivi, lbl = curr.denominazione_regione }) .OrderByDescending(v => v.value) .Take(top) .ToList()); }
public static List <ReturnData> FillRegionDifferentsWithFunction(int region, Func <RegionData, float> func) { List <RegionData> list = DataReaderRegion.ReadRegionData(region) .ToList(); return(list .Select((curr, i) => new ReturnData() { data = curr.data, value = i > 1 ? (func?.Invoke(curr) ?? 0F) - (func?.Invoke(list[i - 1]) ?? 0F) : func?.Invoke(curr) ?? 0F, lbl = curr.data.ToString("dd/MM/yy") } ) .ToList()); }