public IActionResult SearchStudent(string genre, string level, string type) { var students = new List <ClassStudentVM>(); var classes = new List <Class>(); if (genre != null && level != null && type != null) { classes = _classDataAccess.SearchClass(genre, level, type, GetCurrentStudioId()); } else { classes = _classDataAccess.GetAllClasses(GetCurrentStudioId()); } foreach (var _class in classes) { foreach (var id in _classDataAccess.GetStudentsConnectedToClass(_class.Id, GetCurrentStudioId())) { var s = _studentDataAccess.GetStudentById(id); ClassStudentVM student = new ClassStudentVM(); student.Firstname = s.Firstname; student.Lastname = s.Lastname; student.Email = s.Email; student.Genre = _class.Genre; student.Level = _class.Level; students.Add(student); } } return(Json(students)); }
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 IActionResult Index() { ViewBag.text = "User profile"; var user = GetCurrentUser(); ViewBag.StudioName = _studioDataAccess.GetStudioInfo(user.StudioId).Name; var studio = _studioDataAccess.GetStudioInfo(user.StudioId); user.StudioName = studio.Name; user.PhotoUrl = studio.Photo_url; user.NumberOfStudents = _studentDataAccess.GetAllStudents(studio.Id).Count(); user.NumberOfClasses = _classDataAccess.GetAllClasses(studio.Id).Count(); user.NumberOfInstructors = _instructorDataAccess.GetAllInstructors(studio.Id).Count(); return(View("Views/Studio/User.cshtml", user)); }
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); }