public StatistiquesModel ListeStatistiques(string UID_V, string date) { StatistiquesModel stat; DateTime dt = DateTime.Parse(date); Ville ville = db.Villes.Where(v => v.UID == UID_V).FirstOrDefault(); var resuls = db.Enumerations.Where(e => e.Ville.UID == ville.UID && e.Date_Ins == dt).FirstOrDefault(); if (resuls != null) { stat = new StatistiquesModel() { UID = resuls.UID, Cas_Confirmer = (int)resuls.Cas_Confirmer | 0, Cas_Mort = (int)resuls.Cas_Mort | 0, Cas_Retablis = (int)resuls.Cas_Retablis | 0, Total_Cas_Confirmer = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= dt).Sum(r => r.Cas_Confirmer) | 0, Total_Cas_Mort = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= dt).Sum(r => r.Cas_Mort) | 0, Total_Cas_Retablis = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= dt).Sum(r => r.Cas_Retablis) | 0, Date_Ins = ConvertDate.ConverDate((DateTime)resuls.Date_Ins) }; } else { stat = new StatistiquesModel() { Total_Cas_Confirmer = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= dt).Sum(r => r.Cas_Confirmer).GetValueOrDefault() | 0, Total_Cas_Mort = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= dt).Sum(r => r.Cas_Mort).GetValueOrDefault() | 0, Total_Cas_Retablis = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= dt).Sum(r => r.Cas_Retablis).GetValueOrDefault() | 0, Date_Ins = ConvertDate.ConverDate(DateTime.Parse(date)) }; } return(stat); }
public List <StatistiquesModel> GetVilleStatistiquesForDashboard(string UID) { List <StatistiquesModel> lss = new List <StatistiquesModel>(); DateTime dt = db.Enumerations.Min(x => x.Date_Ins).Value; DateTime dtMax = db.Enumerations.Max(x => x.Date_Ins).Value; while (dt != dtMax) { var results = db.Enumerations.Where(s => s.Date_Ins.Value.Day == dt.Day && s.Date_Ins.Value.Month == dt.Month && s.Date_Ins.Value.Year == dt.Year && s.UID_V == UID).ToList(); int TotalCasConfirmer = (int)results.Sum(r => r.Cas_Confirmer).GetValueOrDefault() | 0; int TotalCasMort = (int)results.Sum(r => r.Cas_Mort).GetValueOrDefault() | 0; int TotalCasRetablis = (int)results.Sum(r => r.Cas_Retablis).GetValueOrDefault() | 0; StatistiquesModel st = new StatistiquesModel() { Total_Cas_Confirmer = TotalCasConfirmer, Total_Cas_Mort = TotalCasMort, Total_Cas_Retablis = TotalCasRetablis, Date_Ins = ConvertDate.ConverDate(dt) }; lss.Add(st); dt = dt.AddDays(1); if (dt == dtMax) { break; } } return(lss); }
public List <StatistiquesModel> ListeStatistiques(string UID_V) { Ville ville = db.Villes.Where(v => v.UID == UID_V).FirstOrDefault(); var resuls = db.Enumerations.Where(e => e.Ville.UID == ville.UID).OrderByDescending(o => o.Date_Ins).ToList(); if (resuls.Count > 0) { foreach (var stat in resuls) { StatistiquesModel lst = new StatistiquesModel() { UID = stat.UID, Cas_Confirmer = (int)stat.Cas_Confirmer | 0, Cas_Mort = (int)stat.Cas_Mort | 0, Cas_Retablis = (int)stat.Cas_Retablis | 0, Total_Cas_Confirmer = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= stat.Date_Ins.Value).Sum(r => r.Cas_Confirmer) | 0, Total_Cas_Mort = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= stat.Date_Ins.Value).Sum(r => r.Cas_Mort) | 0, Total_Cas_Retablis = (int)db.Enumerations.Where(e => e.UID_V == UID_V && e.Date_Ins.Value <= stat.Date_Ins.Value).Sum(r => r.Cas_Retablis) | 0, Date_Ins = ConvertDate.ConverDate((DateTime)stat.Date_Ins) }; Statistiques.Add(lst); } } else { Statistiques.Clear(); Statistiques.Add(new StatistiquesModel()); } return(Statistiques); }
public List<StatistiquesModel> ReturnRegStat(string UID_R) { List<StatistiquesModel> ls = new List<StatistiquesModel>(); DateTime d = DateTime.Now; var q = (from s in db.RegionStatistiques where s.UID_R == UID_R orderby s.Date_Ins descending select new { s.UID, s.Cas_Confirmer, s.Cas_Mort, s.Cas_Retablis, s.Date_Ins }).ToList(); if (q != null) { foreach (var item in q) { StatistiquesModel st = new StatistiquesModel() { UID = item.UID, Cas_Confirmer = (int)item.Cas_Confirmer, Cas_Mort = (int)item.Cas_Mort, Cas_Retablis = (int)item.Cas_Retablis, Date_Ins = ConvertDate.ConverDate((DateTime)item.Date_Ins), }; ls.Add(st); } return ls; } return null; }
public StatistiquesModel ListeStatistiques(string UID_R, string date) { StatistiquesModel stat; DateTime dt = DateTime.Parse(date); Region region = db.Regions.Where(r => r.UID == UID_R).FirstOrDefault(); var resuls = db.RegionStatistiques.Where(s => s.UID_R == UID_R && s.Date_Ins == dt).FirstOrDefault(); if (resuls != null) { stat = new StatistiquesModel() { UID = resuls.UID, Cas_Confirmer = (int)resuls.Cas_Confirmer | 0, Cas_Mort = (int)resuls.Cas_Mort | 0, Cas_Retablis = (int)resuls.Cas_Retablis | 0, Total_Cas_Confirmer = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= dt).Sum(r => r.Cas_Confirmer) | 0, Total_Cas_Mort = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= dt).Sum(r => r.Cas_Mort) | 0, Total_Cas_Retablis = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= dt).Sum(r => r.Cas_Retablis) | 0, Date_Ins = ConvertDate.ConverDate((DateTime)resuls.Date_Ins) }; } else { stat = new StatistiquesModel() { Total_Cas_Confirmer = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= dt).Sum(r => r.Cas_Confirmer).GetValueOrDefault() | 0, Total_Cas_Mort = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= dt).Sum(r => r.Cas_Mort).GetValueOrDefault() | 0, Total_Cas_Retablis = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= dt).Sum(r => r.Cas_Retablis).GetValueOrDefault() | 0, Date_Ins = ConvertDate.ConverDate(DateTime.Parse(date)) }; } return(stat); }
public List <StatistiquesModel> ListeStatistiques(string UID_R) { Region region = db.Regions.Where(r => r.UID == UID_R).FirstOrDefault(); var resuls = db.RegionStatistiques.Where(s => s.UID_R == UID_R).OrderByDescending(o => o.Date_Ins).ToList(); if (resuls.Count > 0) { foreach (var stat in resuls) { StatistiquesModel lst = new StatistiquesModel() { UID = stat.UID, Cas_Confirmer = (int)stat.Cas_Confirmer | 0, Cas_Mort = (int)stat.Cas_Mort | 0, Cas_Retablis = (int)stat.Cas_Retablis | 0, Total_Cas_Confirmer = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= stat.Date_Ins.Value).Sum(r => r.Cas_Confirmer) | 0, Total_Cas_Mort = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= stat.Date_Ins.Value).Sum(r => r.Cas_Mort) | 0, Total_Cas_Retablis = (int)db.RegionStatistiques.Where(r => r.UID_R == UID_R && r.Date_Ins.Value <= stat.Date_Ins.Value).Sum(r => r.Cas_Retablis) | 0, Date_Ins = ConvertDate.ConverDate((DateTime)stat.Date_Ins) }; Statistiques.Add(lst); } } else { Statistiques.Clear(); Statistiques.Add(new StatistiquesModel()); } return(Statistiques.OrderByDescending(x => x.Date_Ins).ToList()); }
public APIModel API() { int casC = 0, casM = 0, casR = 0, casT = 0; foreach (var reg in db.Regions.ToList()) { RegionModel Region_ = new RegionModel(); Region_.UID = reg.UID; Region_.Nom = reg.Nom; foreach (var vil in db.Villes.Where(x => x.UID_Region == reg.UID).ToList()) { VilleModel Ville_ = new VilleModel(); Ville_.UID = vil.UID; Ville_.Nom = vil.Nom; foreach (var e in db.Enumerations.Where(e => e.UID_V == vil.UID).ToList()) { StatistiquesModel Statistique_ = new StatistiquesModel() { UID = e.UID, Cas_Confirmer = (int)e.Cas_Confirmer, Cas_Mort = (int)e.Cas_Mort, Cas_Retablis = (int)e.Cas_Retablis, Date_Ins = ConvertDate.ConverDate((DateTime)e.Date_Ins) }; //verify if there is some date to show or show 0 if (e.Cas_Confirmer > 0) casC += (int)e.Cas_Confirmer; if (e.Cas_Retablis > 0) casR += (int)e.Cas_Retablis; if (e.Cas_Mort > 0) casM += (int)e.Cas_Mort; if (Statistique_.UID != null) Ville_.Statistiques.Add(Statistique_); } // add villes with stat in region Region_.Villes.Add(Ville_); } // return Region statis if exists var RegStat = ReturnRegStat(Region_.UID); if (RegStat == null) { RegionStatistique rgS = new RegionStatistique() { UID = GestionGlobal.GetUID("REGSTAT"), Cas_Confirmer = casC, Cas_Mort = casM, Cas_Retablis = casR, Date_Ins = DateTime.Now, UID_R = Region_.UID }; //db.RegionStatistiques.Add(rgS); //db.Entry(rgS).State = System.Data.Entity.EntityState.Added; //db.SaveChanges(); Region_.Statistiques = ReturnRegStat(Region_.UID); } else { RegStat = ReturnRegStat(Region_.UID); Region_.Statistiques = RegStat; } Data.api.Add(Region_); casC = casM = casR = casT = 0; } return Data; }