Beispiel #1
0
        public async Task <ActionResult <List <LabCourse> > > Get([FromHeader] string authToken)
        {
            if (!await _authenticationService.CheckAccess(authToken, "courseView"))
            {
                return(Unauthorized());
            }

            return(await _labCourseService.Get());
        }
Beispiel #2
0
        public async Task <ActionResult <List <LabGroupView> > > Get([FromHeader] string authToken)
        {
            if (!await _authenticationService.CheckAccess(authToken, "groupMgr"))
            {
                return(Unauthorized());
            }

            List <LabGroup> groups = await _labGroupService.Get();

            List <LabGroupView> view = new List <LabGroupView>();


            foreach (LabGroup group in groups)
            {
                LabGroupView temp = LabGroupView.FromGroup(group);

                LabCourse course = await _labCourseService.Get(temp.LabCourseId);

                User prof = await _userService.Get(course.ProfessorId);

                LabBench bench = await _labBenchService.Get(temp.LabBenchId);

                temp.LabCourseName = prof.FirstName + " " + prof.LastName + " " + course.Semester + " " + course.Year + " " + course.Name;

                if (bench != null)
                {
                    temp.LabBenchName = "Lab " + bench.Lab + " Bench " + bench.BenchNum;
                }

                foreach (string userId in temp.Members)
                {
                    User user = await _userService.Get(userId);

                    temp.MembersNames.Add(user.TechId + " " + user.Username);
                }

                view.Add(temp);
            }

            return(view);
        }