public IActionResult Connect([FromBody] RootObjectViewModel coursesList, int studentID) { var service = _serviceManager.NewService <TransactionsService>(_context, _mapper); var addCourses = service.StudentsMatchCourse(coursesList, studentID); return(Ok("Done")); }
public bool StudentsMatchCourse(RootObjectViewModel coursesList, int id) { List <StudentCourse> Addnew = new List <StudentCourse>(); var match = new StudentCourse(); foreach (var item in coursesList.CourseID) { match.StrudentID = id; match.CourseID = item.ID; _context.StudentCourse.Add(match); } _context.SaveChanges(); return(true); }