コード例 #1
0
        public async Task <RegisterCourseDto> RegisterForCourseStudent(RegisterCourseDto registerCourseDto)
        {
            var registerCourseStudent = new StudentProfile()
            {
                StudentId = registerCourseDto.StudentId,
                CourseId  = registerCourseDto.CourseId
            };

            var courses = await _dbContext.StudentProfile.AddAsync(registerCourseStudent);

            _dbContext.SaveChanges();

            return(registerCourseDto);
        }
コード例 #2
0
        public ActionResult <CourseDto> AddStudentCourse(Guid StudentId, RegisterCourseDto course)
        {
            try
            {
                if (_manager.StudentExist(StudentId))
                {
                    return(NotFound());
                }
                var courseEntities = _mapper.Map <Course>(course);
                _manager.RegisterCourse(StudentId, courseEntities);

                var courseToReturn = _mapper.Map <CourseDto>(courseEntities);
                return(CreatedAtRoute("GetStudentCourse", new
                                      { StudentId = StudentId, CourseId = courseToReturn.CourseId },
                                      courseToReturn));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #3
0
        public async Task <IActionResult> registerCourseForStudent(RegisterCourseDto registerCourseDto)
        {
            var courses = await _coursesRepository.RegisterForCourseStudent(registerCourseDto);

            return(Ok(courses));
        }