Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            LeagueManager leagueManager = new LeagueManager(_context);
            League        league        = leagueManager.Get(id) ?? throw new Exception("No league found.");

            return(View(league));
        }
Exemplo n.º 2
0
        public ActionResult League(int id)
        {
            LeagueManager leagueManager = new LeagueManager(_context);
            PlayerManager playerManager = new PlayerManager(_context);
            TradeManager  tradeManager  = new TradeManager(_context);

            League league = leagueManager.Get(id);

            //try get players from session
            List <Player> players = (List <Player>)Session["Players"];

            //try get players from json file
            if (players == null)
            {
                players = JsonConvert.DeserializeObject <List <Player> >(System.IO.File.ReadAllText(@"C:\Users\Collin\Source\Repos\fftoolkit\fftoolkit.Logic\Json Data\players.json"));
            }

            //scrape players
            if (players == null)
            {
                players            = playerManager.Get(league);
                players            = tradeManager.GetTradeValues(players, league);
                Session["Players"] = players;
            }

            //build teams with players

            //try get teams from session
            List <Team> teams = (List <Team>)Session["TeamsWithPlayers"];

            //try get teams from json file
            if (teams == null)
            {
                teams = JsonConvert.DeserializeObject <List <Team> >(System.IO.File.ReadAllText(@"C:\Users\Collin\Source\Repos\fftoolkit\fftoolkit.Logic\Json Data\teams.json"));
            }

            //scrape teams
            if (teams == null)
            {
                teams = tradeManager.GetTeamsWithPlayers(players, league);
                Session["TeamsWithPlayers"] = teams;
            }

            TradesViewModel model = new TradesViewModel(teams)
            {
                League = league
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult CreateTeamMappingForLeague(int id)
        {
            ScraperManager scraperManager = new ScraperManager(_context);
            LeagueManager  leagueManager  = new LeagueManager(_context);
            MappingManager adminManager   = new MappingManager(_context);

            //get league
            League league = leagueManager.Get(id);

            //get standard teams from fantasy pros
            List <Player> players       = scraperManager.ScrapeFantasyPros(0);
            List <string> standardTeams = players.Select(p => p.Team).Distinct().OrderBy(t => t).ToList();

            standardTeams.Insert(0, "");

            ViewBag.StandardTeams = standardTeams;

            //get league data
            List <Team>   teams       = scraperManager.ScrapeLeague(league);
            List <string> leagueTeams = new List <string>();

            //collect distinct list of teams from each team
            foreach (Team team in teams)
            {
                leagueTeams.AddRange(team.Players.Select(p => p.Team).Distinct());
            }

            //collect distinct list of teams
            leagueTeams = leagueTeams.Select(t => t).Distinct().ToList();

            //get unmapped teams for the league
            List <TeamMapping> unmappedTeams = new List <TeamMapping>();

            foreach (string team in leagueTeams)
            {
                if (!standardTeams.Contains(team) && adminManager.GetTeam(team) == null)
                {
                    unmappedTeams.Add(new TeamMapping()
                    {
                        OldTeam = team
                    });
                }
            }

            return(View(unmappedTeams));
        }
Exemplo n.º 4
0
        public ActionResult League(int id)
        {
            LeagueManager leagueManager = new LeagueManager(_context);
            PlayerManager playerManager = new PlayerManager(_context);
            TradeManager  tradeManager  = new TradeManager(_context);

            League        league  = leagueManager.Get(id);
            List <Player> players = playerManager.Get(league);

            players = tradeManager.GetTradeValues(players, league);

            if (players == null || players.Count == 0)
            {
                throw new Exception("No players were loaded.");
            }

            return(View(players));
        }
Exemplo n.º 5
0
 public EntityHttpResponse Get(int id)
 {
     return(new EntityHttpResponse(System.Net.HttpStatusCode.OK, _Leaguemanager.Get(x => x.id == id), true));
 }