Exemplo n.º 1
0
        public IHttpActionResult GetStudentById(int studentId)
        {
            var userData = IdentityHelper.FetchUserData(RequestContext);

            logger.Info("User {@user} requested student with Id {studentId}",
                        IdentityHelper.GetLoggedInUser(userData), studentId);
            return(Ok(service.GetStudentByIdDto(studentId)));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetStudentsByLastName(string lastName)
        {
            var userData = IdentityHelper.FetchUserData(RequestContext);

            logger.Info("User {@user} requested students with last name {lastName}",
                        IdentityHelper.GetLoggedInUser(userData), lastName);

            return(Ok(service.GetStudentsByLastNameStartingWith(lastName)));
        }
Exemplo n.º 3
0
        public IHttpActionResult GetAllStudents()
        {
            var userData = IdentityHelper.FetchUserData(RequestContext);

            logger.Info("User {@user} requested all students",
                        IdentityHelper.GetLoggedInUser(userData));

            return(Ok(service.GetAllStudentsDto()));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetStudentsWithParents()
        {
            var userData = IdentityHelper.FetchUserData(RequestContext);

            logger.Info("User {@user} requested retrieval of all students with their parents",
                        IdentityHelper.GetLoggedInUser(userData));

            return(Ok(service.GetAllStudentsWithParents()));
        }
Exemplo n.º 5
0
        public IHttpActionResult GetWhoAmI()
        {
            var userData = IdentityHelper.FetchUserData(RequestContext);

            if (userData.UserId == null)
            {
                return(NotFound());
            }

            int myId = (int)userData.UserId;

            return(Ok(service.GetUserData(myId)));
        }
Exemplo n.º 6
0
        public IHttpActionResult PostAssignCourseToStudent(int studentId, StudentCourseDto course)
        {
            var userData = IdentityHelper.FetchUserData(RequestContext);

            logger.Info("User {@user} requested assignment of course {@assignment} to student {studentId}",
                        IdentityHelper.GetLoggedInUser(userData), course, studentId);

            var taking = service.AssignCourseToStudent(course);

            if (taking == null)
            {
                return(BadRequest("Course assignment failed"));
            }

            return(Ok(taking));
        }