public async Task <TeamDTO> GetTeamAsync(int id) { Team team = await teams.GetAsync(id); if (team == null) { throw new NotFoundException("Team doesn't exist"); } IEnumerable <TeamMember> currentTeamMembers = await members.GetAllFromTeamAsync(team.Id); var teamMembersDTO = new List <TeamDTO.TeamMember>(); foreach (var member in currentTeamMembers) { AppUser user = await users.GetAsync(member.Id); teamMembersDTO.Add(new TeamDTO.TeamMember { Id = user.Id, UserName = user.UserName }); } return(new TeamDTO { Id = team.Id, Name = team.Name, Members = teamMembersDTO }); }
public async Task <AppUserDTO> GetUserAsync(int id) { AppUser user = await users.GetAsync(id); if (user == null) { throw new NotFoundException("User doesn't exist!"); } return(new AppUserDTO { Id = user.Id, Email = user.Email, UserName = user.UserName }); }