protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FantasyBaseballDataContext fantasyData = new FantasyBaseballDataContext(); int position = int.Parse(Request.QueryString["pos"]); if (position == 11 || position == 12 || position == 13) { var pitchers = from p in fantasyData.GetWaiversPitchersYearly(5, 2007) where p.Position == position && p.Team == null select new { p.Player, p.Position, p.Name, IP = FantasyBaseball.IP(p.Player, p.OUTS), p.W, p.SV, p.SO, K9 = FantasyBaseball.K9(p.Player, p.OUTS, p.SO), p.HLD, ERA = FantasyBaseball.ERA(p.Player, p.OUTS, p.ER), WHIP = FantasyBaseball.WHIP(p.Player, p.OUTS, p.H, p.BB) }; grdPitchers.DataSource = pitchers; grdPitchers.DataKeyNames = new string[] { "Player" }; grdPitchers.DataBind(); } else { var batters = from b in fantasyData.GetWaiversBattersYearly(5, 2007) where b.Position == position && b.Team == null select new { b.Player, b.Position, b.Name, HAB = (b.H.HasValue && b.AB.HasValue) ? b.H.ToString() + "/" + b.AB.ToString() : null, b.R, b.HR, b.RBI, b.SB, AVG = FantasyBaseball.AVG(b.Player, b.AB, b.H), OBP = FantasyBaseball.OBP(b.Player, b.AB, b.BB, b.HBP, b.SF, b.H), SLG = FantasyBaseball.SLG(b.Player, b.AB, b.H, b._2B, b._3B, b.HR), OPS = FantasyBaseball.OBP(b.Player, b.AB, b.BB, b.HBP, b.SF, b.H) + FantasyBaseball.SLG(b.Player, b.AB, b.H, b._2B, b._3B, b.HR) }; grdHitters.DataSource = batters; grdHitters.DataKeyNames = new string[] { "Player" }; grdHitters.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { FantasyBaseballDataContext fantasyData = new FantasyBaseballDataContext(); var teams = from t in fantasyData.TEAMs where t.Owner == int.Parse(Context.User.Identity.Name) select t; rptTeams.DataSource = teams; rptTeams.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FantasyBaseballDataContext fantasyData = new FantasyBaseballDataContext(); int leagueId = int.Parse(Request.QueryString["league"]); var teams = from t in fantasyData.TEAMs where t.League == leagueId select t; grdStandings.DataSource = teams; grdStandings.DataBind(); } }
protected void butAddPlayer_Click(object sender, EventArgs e) { FantasyBaseballDataContext fantasyData = new FantasyBaseballDataContext(); int teamId = int.Parse(Request.QueryString["team"]); int playerId = int.Parse(hidAddPlayer.Value); var roster = (from r in fantasyData.TEAM_ROSTERs where r.Team == teamId && r.Player == playerId select r).SingleOrDefault(); if (roster == null) { roster = new TEAM_ROSTER(); roster.Player = playerId; roster.Team = teamId; fantasyData.TEAM_ROSTERs.InsertOnSubmit(roster); fantasyData.SubmitChanges(); } Response.Redirect(string.Format("roster.aspx?team={0}", teamId)); }