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

            if (userRole == "admin")
            {
                IEnumerable <FormDTOForAdmin> forms = formsService.GetAllForAdmin();
                logger.Info("Success!");
                return(forms);
            }

            else if (userRole == "teacher")
            {
                IEnumerable <FormDTOForTeacher> forms = formsService.GetAllForTeacher();
                logger.Info("Success!");
                return(forms);
            }
            //moze da vidi svoje odeljenje
            else if (userRole == "student")
            {
                IEnumerable <FormDTOForStudentAndParents> forms = formsService.GetAllForStudentFromStudentForm(userId);
                logger.Info("Success!");
                return(forms);
            }
            //moze da vidi sva odeljenja u koja idu njegova deca
            else //if (userRole == "parent")
            {
                IEnumerable <FormDTOForStudentAndParents> forms = formsService.GetAllForParentFromStudentsForms(userId);
                logger.Info("Success!");
                return(forms);
            }
        }