Beispiel #1
0
        public IEnumerable <TeacherDTOForStudentAndParent> GetAllTeachers()
        {
            string userId   = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == "UserId").Value;
            string userRole = ((ClaimsPrincipal)RequestContext.Principal).FindFirst(x => x.Type == ClaimTypes.Role).Value;

            logger.Info("UserRole: " + userRole + ", UserId: " + userId + ": Requesting Student Collection");

            if (userRole == "admin")
            {
                IEnumerable <TeacherDTOForAdmin> users = teachersService.GetAllForAdmin();
                logger.Info("Success!");
                return(users);
            }
            else if (userRole == "teacher")
            {
                IEnumerable <TeacherDTOForTeacher> users = teachersService.GetAllForTeacher();
                logger.Info("Success!");
                return(users);
            }
            else //if (userRole == "student" || userRole == "parent")
            {
                IEnumerable <TeacherDTOForStudentAndParent> users = teachersService.GetAllForStudentAndParent();
                logger.Info("Success!");
                return(users);
            }
        }
        public IHttpActionResult GetAllForTeacher(string id)
        {
            Teacher teacher = teachersService.GetById(id);

            if (teacher == null)
            {
                return(NotFound());
            }

            logger.Info("Requesting teachers view");

            return(Ok(teachersService.GetAllForTeacher(id)));
        }