public async Task <IActionResult> AssignManyStudentsToManyGroupAsync([FromBody] STGAssignmentDTO assignmentDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _service.AssignManyStudentsToManyGroupAsync(assignmentDTO); return(Ok()); }
public async Task AssignManyStudentsToManyGroupAsync(STGAssignmentDTO assignmentDTO) { GroupAssignmentAddDTO stgAssignment = new GroupAssignmentAddDTO(); foreach (var group in assignmentDTO.GroupIds) { foreach (var student in assignmentDTO.StudentIds) { stgAssignment.UserId = student; stgAssignment.GroupId = group; await AssignStudentsToGroupAsync(stgAssignment); stgAssignment = new GroupAssignmentAddDTO(); } } }