public async Task <List <StudentCoursesDto> > GetStudentCourses(StudentCourseInputDto input) { List <StudentCoursesDto> studentCoursesDto = new List <StudentCoursesDto>(); var studentCourses = await _context.StudentCourse.Include(x => x.Course).Where(x => x.StudentGuid == input.StudentGuid).ToListAsync(); if (studentCourses != null) { studentCoursesDto = Mapper.Map <List <StudentCoursesDto> >(studentCourses); } return(studentCoursesDto); }
public async Task <bool> AddStudentCourse(StudentCourseInputDto input) { if (input != null) { foreach (var course in input.Courses) { StudentCourses s1 = new StudentCourses(); s1.CourseGuid = course.Id.Value; s1.StudentGuid = input.StudentGuid; _context.Add(s1); } } await _context.SaveChangesAsync(); return(true); }