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));
        }
예제 #2
0
        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));
        }