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); }
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); } }
public async Task <IActionResult> registerCourseForStudent(RegisterCourseDto registerCourseDto) { var courses = await _coursesRepository.RegisterForCourseStudent(registerCourseDto); return(Ok(courses)); }