Exemplo n.º 1
0
 public TeamPontuationService(ITeamPontuationRepository teamPontuationRepository, ITeamRepository teamRepository,
                              IPlayerPontuationService playerPontuation, IMatchRepository matchRepository)
 {
     _teamPontuationRepository = teamPontuationRepository;
     _teamRepository           = teamRepository;
     _playerPontuation         = playerPontuation;
     _matchRepository          = matchRepository;
 }
Exemplo n.º 2
0
        public PontuationModule(IBootstrapInjection injection)
        {
            _playerPontuation = injection.Services.PlayerPontuation;
            Get[EndpointConfigurationEnum.GET_PLAYER_PONTUATION] = p =>
            {
                var result = _playerPontuation.GetPlayersPontuations().Select(c => new PlayerPontuationDTO(c))
                             .OrderByDescending(c => c.TotalMatches)
                             .ToList();
                return(Response.AsJson(result));
            };

            Get[EndpointConfigurationEnum.GET_SOLO_TEAM_PONTUATION] = p =>
            {
                int view       = Convert.ToInt32(p.view.Value);
                int minMatches = Convert.ToInt32(p.minMatches.Value);
                var result     = _playerPontuation.GetSoloTeamsPontuations(minMatches, view).Select(c => new PlayerPontuationDTO(c))
                                 .OrderByDescending(c => c.TotalMatches)
                                 .ToList();
                return(Response.AsJson(result));
            };

            Get[EndpointConfigurationEnum.GET_POSITION_PONTUATION] = p =>
            {
                var id         = p.id.Value.ToString();
                var pontuation = injection.Services.PlayerPontuation.GetPlayerPositionPontuation(id);
                return(Response.AsJson(new PositionDTO(pontuation)));
            };

            Get[EndpointConfigurationEnum.GET_DUO_TEAM_PONTUATION] = p =>
            {
                int view       = Convert.ToInt32(p.view.Value);
                int minMatches = Convert.ToInt32(p.minMatches.Value);
                var result     = _playerPontuation.GetSoloBestDuosPontuation(minMatches, view).Select(c => new PlayerPontuationDTO(c))
                                 .OrderByDescending(c => c.TotalMatches)
                                 .ToList();
                return(Response.AsJson(result));
            };

            Get[EndpointConfigurationEnum.GET_PLAYER_PONTUATION_BY_ID] = p =>
            {
                var id = p.userId;
                List <PlayerPontuationDTO> result = new List <PlayerPontuationDTO>();
                List <ScorePontuation>     oi     = _playerPontuation.GetPlayerInfo(id);
                return(Response.AsJson(oi.Select(c => new PlayerPontuationDTO(c)).ToList()));
            };

            Get[EndpointConfigurationEnum.GET_PLAYER_PONTUATION_BY_ID_AND_DATE] = p =>
            {
                var      id    = p.userId;
                DateTime from  = DateTime.ParseExact(p.from, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                DateTime until = DateTime.ParseExact(p.until, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                List <PlayerPontuationDTO> result = new List <PlayerPontuationDTO>();
                List <ScorePontuation>     oi     = _playerPontuation.GetPlayerInfo(id, from, until);
                return(Response.AsJson(oi.Select(c => new PlayerPontuationDTO(c)).ToList()));
            };

            Get[EndpointConfigurationEnum.GET_PLAYER_LINE_GRAPH] = p =>
            {
                var id   = p.userId;
                int type = 0;
                int.TryParse(p.typ.Value, out type);

                int period = 0;
                int.TryParse(p.period.Value, out period);
                LineGraph result = _playerPontuation.GetLineGraph(id, period, type);
                return(Response.AsJson(result));
            };
        }