public TeamDto AddTeam(TeamDto team) { authenticator.AuthenticateAdmin(); Team added = TryAddTeam(team); return(mapper.ToDto(added)); }
private ICollection <Tuple <TeamDto, int> > CalculateExistingSportTable(Sport aSport) { ICollection <Team> sportTeams = teamsStorage.GetTeams(aSport.Name); ICollection <Encounter> teamsEncounters = matchesService.GetAllEncounters(aSport.Name); ICollection <Tuple <Team, int> > positions; if (aSport.IsTwoTeams) { positions = CalculateMatchesTable(sportTeams, teamsEncounters); } else { positions = CalculateCompetitionsTable(sportTeams, teamsEncounters); } return(positions .Select(t => new Tuple <TeamDto, int>(mapper.ToDto(t.Item1), t.Item2)) .ToList()); }
public ICollection <TeamDto> GetUserTeams(string userName) { authenticator.Authenticate(); ICollection <Team> userTeams; try { User fetched = usersStorage.Get(userName); userTeams = fetched.GetFavouriteTeams(); } catch (EntityNotFoundException e) { throw new ServiceException(e.Message, ErrorType.ENTITY_NOT_FOUND); }catch (DataInaccessibleException e) { throw new ServiceException(e.Message, ErrorType.DATA_INACCESSIBLE); } return(userTeams .Select(ut => teamMapper.ToDto(ut)) .ToList()); }