Пример #1
0
        public IEnumerable <ParentDTOForStudentAndParents> GetAllParents()
        {
            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 Parent Collection");

            if (userRole == "admin")
            {
                IEnumerable <ParentDTOForAdmin> users = parentsService.GetAllForAdmin();
                logger.Info("Success!");
                return(users);
            }
            else if (userRole == "teacher")
            {
                IEnumerable <ParentDTOForTeacher> users = parentsService.GetAllForTeacher();
                logger.Info("Success!");
                return(users);
            }
            //moze da vidi sve roditelje ucenika svog razreda
            else if (userRole == "student")
            {
                IEnumerable <ParentDTOForStudentAndParents> users = parentsService.GetAllForStudentFromStudentForm(userId);
                logger.Info("Success!");
                return(users);
            }
            //moze da vidi sve roditelje ucenika onih razreda u koja idu njegova deca
            else //if (userRole == "parent")
            {
                IEnumerable <ParentDTOForStudentAndParents> users = parentsService.GetAllForParentFromStudentsForms(userId);
                logger.Info("Success!");
                return(users);
            }
        }