예제 #1
0
        public CustomHttpResponseMessage GetTotalPlayers(string leagueCode)
        {
            var competition  = _competitionRepository.GetSingle(x => x.Code == leagueCode.ToUpper(), i => i.Teams);
            var totalPlayers = competition?.Teams.Sum(x => x.TotalPlayers);

            if (!totalPlayers.HasValue)
            {
                return(CustomHttpResponseMessage.NotFound());
            }

            return(CustomHttpResponseMessage.TotalPlayers(totalPlayers.Value));
        }
예제 #2
0
        public async Task <CustomHttpResponseMessage> Handle(string leagueCode)
        {
            if (_competitionRepository.GetList(x => x.Code == leagueCode.ToUpper()).Any())
            {
                return(CustomHttpResponseMessage.LeagueAlreadyImported());
            }

            var competitionResponse = await _mediator.Send(new GetCompetitionRequest(leagueCode));

            if (!competitionResponse.IsSuccess)
            {
                return(CustomHttpResponseMessage.ServerError());
            }

            if (competitionResponse.Competition == null)
            {
                return(CustomHttpResponseMessage.NotFound());
            }

            SaveTeam(await SaveCompetition(competitionResponse));

            return(CustomHttpResponseMessage.LeagueCreated());
        }