public void InsertHistoryTransactionRecord(RosterTransactionModel rtmodel) { int result = -100; using (var conn = _db.CreateConnection()) using (var cmd = conn.CreateCommand()) { cmd.CommandText = @" Insert into roster_trans_history (roster_trans_id,roster_trans_type_id,player_id,team_code,effective_date) values(@rostertransid,@rosterTranscationTypeId ,@player_id , @team_code ,@effective_date)"; SqlParameter rostertransid = new SqlParameter(); rostertransid.ParameterName = "@rostertransid"; rostertransid.Value = rtmodel.rosterTranscationId; SqlParameter rosterTranscationTypeId = new SqlParameter(); rosterTranscationTypeId.ParameterName = "@rosterTranscationTypeId"; rosterTranscationTypeId.Value = rtmodel.rosterTransactionTypeId; SqlParameter player_id = new SqlParameter(); player_id.ParameterName = "@player_id"; player_id.Value = rtmodel.player_id; SqlParameter team_code = new SqlParameter(); team_code.ParameterName = "@team_code"; team_code.Value = rtmodel.team_code; SqlParameter effective_date = new SqlParameter(); effective_date.ParameterName = "@effective_date"; effective_date.Value = rtmodel.effective_date; cmd.Parameters.Add(rostertransid); cmd.Parameters.Add(rosterTranscationTypeId); cmd.Parameters.Add(player_id); cmd.Parameters.Add(team_code); cmd.Parameters.Add(effective_date); result = cmd.ExecuteNonQuery(); } }
public string AddPlayerToTeam(string fname, string lname, string tcode, DateTime dt) { string result = string.Empty; if (TeamHasCapacity(tcode)) { int pid = _pservice.AddNewPlayer(fname, lname); int playerId = _pservice.GetLatestPlayer(); RosterTransactionModel rtm = new RosterTransactionModel() { rosterTransactionTypeId = (int)TransactionType.Signed, player_id = playerId, effective_date = dt, team_code = tcode }; int rtId = _rtservice.AddPlayerTransaction(rtm); if (rtId == 1) { return("player has been successfuly created"); } else { return("There was an error, player has not been created"); } } else { return("Team size is at max. Player has not been created"); } }
public string TradePlayer(int playerId, string teamCode, DateTime effdt) { int playerStatus = CheckPlayerStatus(playerId); string result = string.Empty; RosterTransactionModel rtmodel = _rtservice.GetRtForPlayerById(playerId); if (TeamHasCapacity(teamCode)) { if (playerStatus != (int)TransactionType.Injured) { int resp = _rtservice.UpdatePlayerTeam(playerId, teamCode, effdt); if (resp == 1) { result = $"player successufly traded to {teamCode}"; _rhservice.InsertHistoryTransactionRecord(rtmodel); } else { result = "please check the trade information"; } } } else { result = "Team is at capacity can not trade"; } return(result); }
public int SetPlayerStatusToInjured(int playerId, DateTime efdate) { RosterTransactionModel rmodel = _rtservice.GetRtForPlayerById(playerId); rmodel.effective_date = efdate; _rhservice.InsertHistoryTransactionRecord(rmodel); int result = _rtservice.UpdatePlayerTType(playerId, (int)TransactionType.Injured, efdate); return(result); }
public string SignPlayer(int playerId, DateTime effdate) { int playerStatus = CheckPlayerStatus(playerId); string result = string.Empty; RosterTransactionModel rtmodel = _rtservice.GetRtForPlayerById(playerId); if (playerStatus == (int)TransactionType.Healthy) { int resp = _rtservice.UpdatePlayerTType(playerId, (int)TransactionType.Signed, effdate); if (resp == 1) { result = $"player successufly signed "; _rhservice.InsertHistoryTransactionRecord(rtmodel); } else { result = "please check the trade information"; } } return(result); }
public int CheckPlayerStatus(int playerId) { RosterTransactionModel rmodel = _rtservice.GetRtForPlayerById(playerId); return(rmodel.rosterTransactionTypeId); }