public void GetStundenPlanbyDatumAndKlasse() { var con = DbHelper.GetDbConnection(); con.Open(); var result = StundeplanAccess.GetStundenplanByKlassAndDate(con, 1, DateTime.Today.ToString("yyyy-MM-dd")); foreach (var item in result) { item.Klasse = StundeplanAccess.GetKlasseText(con, item.Klasse_ID); item.Lehrer = StundeplanAccess.GetLehrerText(con, item.Lehrer_ID); item.Raum = StundeplanAccess.GetRaumText(con, item.Raum_ID); item.Fach = StundeplanAccess.GetRaumText(con, item.Fach_ID); item.Notiz = StundeplanAccess.GetNotiz(con, item.Notiz_ID); item.Notiz.User_Name = UserAccess.GetNameByID(con, item.Notiz.User_ID); } con.Close(); Console.Write("OK"); }
/// <summary> /// Liefert den Stundenplan und Notizen für eine Woche anhand der Klasse und einem Datum /// </summary> /// <param name="Klasse">Klasse</param> /// <param name="date">Datum</param> /// <returns>Eine Liste aus Elementen vom Typ StundenplanModel</returns> public WocheModel GetStundenplan(int klasse, string date) { var today = DateTime.Parse(date); var con = DbHelper.GetDbConnection(); con.Open(); int currentDayOfWeek = (int)today.DayOfWeek; DateTime sunday = today.AddDays(-currentDayOfWeek); DateTime monday = sunday.AddDays(1); if (currentDayOfWeek == 0) { monday = monday.AddDays(-7); } var dates = Enumerable.Range(0, 7).Select(days => monday.AddDays(days)).ToList(); var woche = new WocheModel(); for (int i = 0; i <= 4; i++) { if (i == 0) { woche.monday = StundeplanAccess.GetStundenplanByKlassAndDate(con, klasse, dates[i].ToString("yyyy-MM-dd")); foreach (var item in woche.monday) { item.Klasse = StundeplanAccess.GetKlasseText(con, item.Klasse_ID); item.Lehrer = StundeplanAccess.GetLehrerText(con, item.Lehrer_ID); item.Raum = StundeplanAccess.GetRaumText(con, item.Raum_ID); item.Fach = StundeplanAccess.GetFachText(con, item.Fach_ID); item.Status = StundeplanAccess.GetStatusText(con, item.Status_ID); } } if (i == 1) { woche.tuesday = StundeplanAccess.GetStundenplanByKlassAndDate(con, klasse, dates[i].ToString("yyyy-MM-dd")); foreach (var item in woche.tuesday) { item.Klasse = StundeplanAccess.GetKlasseText(con, item.Klasse_ID); item.Lehrer = StundeplanAccess.GetLehrerText(con, item.Lehrer_ID); item.Raum = StundeplanAccess.GetRaumText(con, item.Raum_ID); item.Fach = StundeplanAccess.GetFachText(con, item.Fach_ID); item.Status = StundeplanAccess.GetStatusText(con, item.Status_ID); } } if (i == 2) { woche.wednesday = StundeplanAccess.GetStundenplanByKlassAndDate(con, klasse, dates[i].ToString("yyyy-MM-dd")); foreach (var item in woche.wednesday) { item.Klasse = StundeplanAccess.GetKlasseText(con, item.Klasse_ID); item.Lehrer = StundeplanAccess.GetLehrerText(con, item.Lehrer_ID); item.Raum = StundeplanAccess.GetRaumText(con, item.Raum_ID); item.Fach = StundeplanAccess.GetFachText(con, item.Fach_ID); item.Status = StundeplanAccess.GetStatusText(con, item.Status_ID); } } if (i == 3) { woche.thursday = StundeplanAccess.GetStundenplanByKlassAndDate(con, klasse, dates[i].ToString("yyyy-MM-dd")); foreach (var item in woche.thursday) { item.Klasse = StundeplanAccess.GetKlasseText(con, item.Klasse_ID); item.Lehrer = StundeplanAccess.GetLehrerText(con, item.Lehrer_ID); item.Raum = StundeplanAccess.GetRaumText(con, item.Raum_ID); item.Fach = StundeplanAccess.GetFachText(con, item.Fach_ID); item.Status = StundeplanAccess.GetStatusText(con, item.Status_ID); } } if (i == 4) { woche.friday = StundeplanAccess.GetStundenplanByKlassAndDate(con, klasse, dates[i].ToString("yyyy-MM-dd")); foreach (var item in woche.friday) { item.Klasse = StundeplanAccess.GetKlasseText(con, item.Klasse_ID); item.Lehrer = StundeplanAccess.GetLehrerText(con, item.Lehrer_ID); item.Raum = StundeplanAccess.GetRaumText(con, item.Raum_ID); item.Fach = StundeplanAccess.GetFachText(con, item.Fach_ID); item.Status = StundeplanAccess.GetStatusText(con, item.Status_ID); } } } woche.weekNotes = NotizAccess.GetWochenNotizenByID(con, dates[0].ToString("yyyy-MM-dd"), dates[4].ToString("yyyy-MM-dd"), klasse); return(woche); }