public async Task RemoveUsersFromTeam(RemoveUsersFromTeam command) { await _administratorService.ValidateAtLeastAdministrator(command.UserId, command.GroupId); var group = await _groupRepository.GetWithTeamStudentsAsync(command.GroupId); var team = group.Teams.FirstOrDefault(t => t.Name == command.TeamName); if (team == null) { throw new AppException($"Team {command.TeamName} doesn't exist", AppErrorCode.DOESNT_EXIST); } team.RemoveStudents(command.Emails, command.UserId); await _groupRepository.SaveChangesAsync(); }
public async Task <ActionResult> RemoveUsersFromTeam(Guid groupId, string teamName, [FromBody] RemoveUsersFromTeam command) { command.GroupId = groupId; command.TeamName = teamName; command.UserId = User.GetUserId(); await _teamService.RemoveUsersFromTeam(command); return(Ok()); }