public static Batter Create(ESPNProjections.IPlayer batter) { Batter b = new Batter(); b.AuctionPrice = 0; b.FantasyTeam = string.Empty; b.Update(batter); return(b); }
public void UpdateESPNProjections() { Dictionary <int, Batter> batterMap = new Dictionary <int, Batter>(); foreach (var batter in this.Batters) { batterMap[batter.ESPNId] = batter; } Dictionary <int, Pitcher> pitcherMap = new Dictionary <int, Pitcher>(); foreach (var pitcher in this.Pitchers) { pitcherMap[pitcher.ESPNId] = pitcher; } foreach (ESPNProjections.Player player in ESPNProjections.Player.LoadProjections()) { if (player.IsBatter) { Batter b; if (batterMap.TryGetValue(player.Id, out b)) { b.Update(player); } else { b = Batter.Create(player); batterMap[b.ESPNId] = b; } } else { Pitcher p; if (pitcherMap.TryGetValue(player.Id, out p)) { p.Update(player); } else { p = Pitcher.Create(player); pitcherMap[p.ESPNId] = p; } } } if (this.Batters.Length != batterMap.Count) { this.Batters = new List <Batter>(batterMap.Values).ToArray(); } if (this.Pitchers.Length != pitcherMap.Count) { this.Pitchers = new List <Pitcher>(pitcherMap.Values).ToArray(); } }