/* ******************************************************* * */ public void AddLeague(DLeague league) { using (var cmd = new SqlCmdExt(_connectionString)) { cmd.CreateCmd(@" INSERT INTO League (Name) VALUES (@Name) "); cmd.SetInArg("@Name", league.Name); cmd.ExecuteInsertUpdateDelete(); } }
/* ******************************************************* * */ public void AddProspect(DProspect prospect) { using (var cmd = new SqlCmdExt(_connectionString)) { cmd.CreateCmd(@" INSERT INTO Prospect ( Name, TeamId, Height, Weight, PositionId, HandednessId, BirthDay, DraftYear, BirthCity, BirthCountry, Notes ) VALUES ( @Name, @TeamId, @Height, @Weight, @PositionId, @HandednessId, @BirthDay, @DraftYear, @BirthCity, @BirthCountry, @Notes )"); cmd.SetInArg("@Name", prospect.Name); cmd.SetInArg("@TeamId", prospect.Team.Id); cmd.SetInArg("@Height", prospect.Height); cmd.SetInArg("@Weight", prospect.Weight); cmd.SetInArg("@PositionId", GetPositionId(prospect.Position)); cmd.SetInArg("@HandednessId", GetHandednessId(prospect.Handedness)); cmd.SetInArg("@BirthDay", prospect.BirthDay); cmd.SetInArg("@DraftYear", prospect.DraftYear); cmd.SetInArg("@BirthCity", prospect.BirthCity); cmd.SetInArg("@BirthCountry", prospect.BirthCountry); cmd.SetInArg("@Notes", prospect.Notes); cmd.ExecuteInsertUpdateDelete(); } }
private DTeam InstantiateTeam(SqlCmdExt cmd) { var team = new DTeam { Id = cmd.GetInt("Id"), Name = cmd.GetString("Name"), League = GetLeague(cmd.GetInt("LeagueId")) }; return team; }
private SqlCmdExt Select(string command) { var cmd = new SqlCmdExt(_connectionString); cmd.CreateCmd(command); cmd.ExecuteSelect(); return cmd; }
private DProspect InstantiateProspect(SqlCmdExt cmd) { var dProspect = new DProspect { Id = cmd.GetInt("Id"), Name = cmd.GetString("Name"), Team = GetTeam(cmd.GetInt("TeamId")), Height = cmd.GetInt("Height"), Weight = cmd.GetInt("Weight"), Position = GetPosition(cmd.GetInt("PositionId")), Handedness = GetHandedness(cmd.GetInt("HandednessId")), BirthDay = cmd.GetDateTime("BirthDay"), DraftYear = cmd.GetInt("DraftYear"), BirthCity = cmd.GetString("BirthCity"), BirthCountry = cmd.GetString("BirthCountry"), Notes = cmd.GetString("Notes") }; return dProspect; }
private DLeague InstantiateLeague(SqlCmdExt cmd) { var league = new DLeague { Id = cmd.GetInt("Id"), Name = cmd.GetString("Name") }; return league; }
/* ******************************************************* * */ public void AddTeam(DTeam team) { using (var cmd = new SqlCmdExt(_connectionString)) { cmd.CreateCmd(@" INSERT INTO Team (Name, LeagueId) VALUES (@Name, @LeagueId) "); cmd.SetInArg("@Name", team.Name); cmd.SetInArg("@LeagueId", team.League.Id); cmd.ExecuteInsertUpdateDelete(); } }
private void LoadHandednessPairs() { var idToHandedness = new Dictionary<int, string>(); var handednessToId = new Dictionary<string, int>(); using (var cmd = new SqlCmdExt(_connectionString)) { cmd.CreateCmd(@" SELECT Id, Hand FROM Handedness "); cmd.ExecuteSelect(); while (cmd.Read()) { var id = cmd.GetInt("Id"); var hand = cmd.GetString("Hand"); idToHandedness.Add(id, hand); handednessToId.Add(hand, id); } } _idToHandedness = idToHandedness; _handednessToId = handednessToId; }
/* ******************************************************* * */ private void LoadPositionPairs() { var idToPosition = new Dictionary<int, string>(); var positionToId = new Dictionary<string, int>(); using (var cmd = new SqlCmdExt(_connectionString)) { cmd.CreateCmd(@" SELECT Id, Position FROM Position "); cmd.ExecuteSelect(); while (cmd.Read()) { var id = cmd.GetInt("Id"); var position = cmd.GetString("Position"); idToPosition.Add(id, position); positionToId.Add(position, id); } } _idToPosition = idToPosition; _positionToId = positionToId; }