public async Task <IActionResult> UpdateStudent([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.UpdateStudentTaskAsync(request.Object.Student, token); if (response.StatusCode != HttpStatusCode.Created) { return(View("/Views/Coordinator/Students/Update.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)); }
public async Task <IActionResult> Index([FromServices] StudentsService studentsService) { string token = User.FindFirst("Token").Value; ResultModel <List <StudentDisciplineVO> > students = await studentsService.GetStudentsTaskAsync(token); return(View("/Views/Coordinator/Students/Index.cshtml", students)); }
public async Task <IActionResult> Delete([FromServices] StudentsService studentsService, [Required] Guid studentId) { if (ModelState.IsValid) { string token = User.FindFirst("Token").Value; ResultModel <bool> response = await studentsService.RemoveStudentTaskAsync(studentId, token); ResultModel <List <StudentDisciplineVO> > studentResponse = await studentsService.GetStudentsTaskAsync(token); studentResponse.Message = response.Message; studentResponse.StatusCode = response.StatusCode; return(View("/Views/Coordinator/Students/Index.cshtml", studentResponse)); } return(NotFound()); }