예제 #1
0
        public async Task <List <PlayerDetailsDTO> > GetImpendingFreeAgents(int year)
        {
            var salaries = await _api.GetSalaries();

            var oneYearPlayers = salaries.Salaries.LeagueUnit.Player.Where(p => p.ContractYear == "1").ToList();

            // get names via other get call
            string queryParam = "";

            oneYearPlayers.ForEach(p => queryParam = $"{queryParam}{p.Id},");

            var playerDetails = await _globalApi.GetPlayerDetails(queryParam);

            var playerDetailsList = playerDetails.playerProfiles.playerProfile.ToList();
            //map to DTO

            var DTOs = _mapper.Map <List <MflPlayerProfile>, List <PlayerDetailsDTO> >(playerDetailsList);

            foreach (var d in DTOs)
            {
                var match = oneYearPlayers.First(_ => _.Id == d.Id);
                d.Salary = match.Salary;
            }

            return(DTOs);
        }
예제 #2
0
        public async Task PostFranchiseTagAmounts()
        {
            var salariesTask = _mfl.GetSalaries();
            var positionTask = _mfl.GetAllMflPlayers();
            await Task.WhenAll(salariesTask, positionTask);

            var positionIds = positionTask.Result.players.player.Where(p =>
                                                                       p.position == "WR" || p.position == "QB" || p.position == "RB" || p.position == "TE").ToList();
            var playerSalaries = salariesTask.Result.Salaries.LeagueUnit.Player.Select(_ => new
            {
                Salary = Decimal.TryParse(_.Salary, out var sal) ? sal : 0,
                Id     = _.Id
            }).ToList();