コード例 #1
0
        public TeamDto AddTeam(TeamDto team)
        {
            authenticator.AuthenticateAdmin();
            Team added = TryAddTeam(team);

            return(mapper.ToDto(added));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }