Ejemplo n.º 1
0
        public async Task <IActionResult> AddStudent([FromServices] StudentsService studentsService, ResultModel <StudentDisciplineVO> request)
        {
            string token = User.FindFirst("Token").Value;

            request.Object.Student.CourseId = Guid.Parse(User.FindFirst("CourseId").Value);

            ResultModel <StudentDisciplineVO> response = await studentsService.AddStudentTaskAsync(request.Object.Student, token);

            if (response.StatusCode != HttpStatusCode.Created)
            {
                return(View("/Views/Coordinator/Students/Add.cshtml", new ResultModel <StudentDisciplineVO>
                {
                    Object = request.Object,
                    Message = response.Message,
                    StatusCode = response.StatusCode
                }));
            }

            ResultModel <List <StudentDisciplineVO> > studentResponse = await studentsService.GetStudentsTaskAsync(token);

            if (studentResponse.StatusCode == HttpStatusCode.OK)
            {
                studentResponse.Message    = response.Message;
                studentResponse.StatusCode = response.StatusCode;
            }

            return(View("/Views/Coordinator/Students/Index.cshtml", studentResponse));
        }