Exemplo n.º 1
0
        public async Task <IActionResult> SelectCourses(List <CourseNameIdDto> courses)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(
                           "GetCoursesToChoose",
                           routeValues: new { error = _config["ErrorCodes:model_state"] }
                           ));
            }

            var id = HttpContext.User.Claims
                     .FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
            var idGuid       = Guid.Parse(id);
            var repoResponse = await _repo.ChooseCourses(idGuid, courses);

            if (!repoResponse.IsSuccess)
            {
                return(RedirectToAction(
                           "GetCoursesToChoose",
                           routeValues: new { error = repoResponse.Message }
                           ));
            }

            return(RedirectToAction(
                       actionName: "GetStudentProfile",
                       controllerName: "Auth"
                       ));
        }