public IActionResult Dashboard() { ViewBag.text = "Dashboard"; ViewBag.StudioName = _studioDataAccess.GetStudioInfo(GetCurrentStudioId()).Name; DashboardNeeds dashboardNeeds = new DashboardNeeds(); var allClasses = _classDataAccess.GetAllClasses(GetCurrentStudioId()); var allStudents = _studentDataAccess.GetAllStudents(GetCurrentStudioId()); var allInstructors = _instructorDataAccess.GetAllInstructors(GetCurrentStudioId()); foreach (var _class in allClasses) { var classShedule = _classDataAccess.GetClassShedule(_class.Id); foreach (var s in classShedule) { if (s.Day == DateTime.Now.DayOfWeek.ToString() && _class.StartDay <= DateTime.Now) { _class.Hour = s.Hour; dashboardNeeds.classesForToday.Add(_class); } } } foreach (var st in allStudents) { var sL = new SelectListItem() { Value = st.Id.ToString(), Text = $"{st.Firstname} {st.Lastname}" }; dashboardNeeds.AllStudents.Add(sL); } foreach (var ins in allInstructors) { var iL = new SelectListItem() { Value = ins.Id.ToString(), Text = $"{ins.Firstname} {ins.Lastname}" }; dashboardNeeds.AllInstructors.Add(iL); } return(View(dashboardNeeds)); }
public List <CalendarData> GetAllClassesShedule(CalendarSearchVM calendarSearch, int studioId) { var calData = new List <CalendarData>(); List <Class> classes = classDataAccess.GetAllClasses(studioId); foreach (var _class in classes) { List <Shedule> shedules = classDataAccess.GetClassShedule(_class.Id); List <int> idInstructors = classDataAccess.GetInstructorsConnectedToClass(_class.Id, studioId); List <Instructor> instructors = new List <Instructor>(); foreach (var id in idInstructors) { instructors.Add(instructorDataAccess.GetInstructorById(id)); } foreach (var s in shedules) { List <DayVM> classesDays = new List <DayVM>(); foreach (var day in calendarSearch.Days) { if ((day.Day.DayOfWeek.ToString() == s.Day) && _class.StartDay.Date < day.Day.Date) { classesDays.Add(new DayVM { Day = day.Day.Date, WorkDay = day.WorkDay }); } } calData.Add(new CalendarData { Hour = s.Hour, Level = _class.Level, Name = _class.Genre, SheduleDays = classesDays, Instructors = instructors, NumberOfStudents = _class.NumberOfStudents }); } } return(calData); }