public AbilityAssociatedRecords SP_GetAbilityCommands(int abilityId, int RuleSetID) { AbilityAssociatedRecords result = new AbilityAssociatedRecords(); string connectionString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value; string qry = "Exec Ability_GetAbilityCommands @AbilityId ='" + abilityId + "',@RulesetID='" + RuleSetID + "'"; using (SqlConnection Connection = new SqlConnection(connectionString)) { try { Connection.Open(); var abilityrecord = Connection.QueryMultiple(qry); if (abilityrecord != null) { result.AbilityCommands = abilityrecord.Read <AbilityCommand>().ToList(); result.BuffAndEffectsList = abilityrecord.Read <BuffAndEffect>().ToList(); result.SelectedBuffAndEffects = abilityrecord.Read <BuffAndEffect>().ToList(); } } catch (Exception ex) { throw ex; } finally { Connection.Close(); } } return(result); }
public AbilityAssociatedRecords SP_GetAbilityCommands_Old(int abilityId, int RuleSetID) { AbilityAssociatedRecords result = new AbilityAssociatedRecords(); List <AbilityCommand> _abilityCommand = new List <AbilityCommand>(); List <BuffAndEffect> _BuffAndEffects = new List <BuffAndEffect>(); List <BuffAndEffect> _selectedBuffAndEffects = new List <BuffAndEffect>(); string connectionString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value; // string qry = "EXEC Ability_GetAbilityCommands @AbilityId = '" + abilityId + "'"; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(); SqlDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); try { connection.Open(); command = new SqlCommand("Ability_GetAbilityCommands", connection); // Add the parameters for the SelectCommand. command.Parameters.AddWithValue("@AbilityId", abilityId); command.Parameters.AddWithValue("@RulesetID", RuleSetID); command.CommandType = CommandType.StoredProcedure; adapter.SelectCommand = command; adapter.Fill(ds); command.Dispose(); connection.Close(); } catch (Exception ex) { command.Dispose(); connection.Close(); } if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { AbilityCommand _cmd = new AbilityCommand(); _cmd.Command = row["Command"] == DBNull.Value ? null : row["Command"].ToString(); _cmd.AbilityId = row["AbilityId"] == DBNull.Value ? 0 : Convert.ToInt32(row["AbilityId"].ToString()); _cmd.AbilityCommandId = row["AbilityCommandId"] == DBNull.Value ? 0 : Convert.ToInt32(row["AbilityCommandId"].ToString()); _cmd.IsDeleted = row["IsDeleted"] == DBNull.Value ? false : Convert.ToBoolean(row["IsDeleted"]); _cmd.Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(); _abilityCommand.Add(_cmd); } } if (ds.Tables[1].Rows.Count > 0) { foreach (DataRow row in ds.Tables[1].Rows) { BuffAndEffect i = new BuffAndEffect(); i.BuffAndEffectId = row["BuffAndEffectId"] == DBNull.Value ? 0 : Convert.ToInt32(row["BuffAndEffectId"]); i.RuleSetId = row["RuleSetId"] == DBNull.Value ? 0 : Convert.ToInt32(row["RuleSetId"]); i.Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(); i.ImageUrl = row["ImageUrl"] == DBNull.Value ? null : row["ImageUrl"].ToString(); _BuffAndEffects.Add(i);///////// } } if (ds.Tables[2].Rows.Count > 0) { foreach (DataRow row in ds.Tables[2].Rows) { BuffAndEffect i = new BuffAndEffect(); i.BuffAndEffectId = row["BuffAndEffectId"] == DBNull.Value ? 0 : Convert.ToInt32(row["BuffAndEffectId"]); i.RuleSetId = row["RuleSetId"] == DBNull.Value ? 0 : Convert.ToInt32(row["RuleSetId"]); i.Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(); i.ImageUrl = row["ImageUrl"] == DBNull.Value ? null : row["ImageUrl"].ToString(); _selectedBuffAndEffects.Add(i);/////// } } result.AbilityCommands = _abilityCommand; result.BuffAndEffectsList = _BuffAndEffects; result.SelectedBuffAndEffects = _selectedBuffAndEffects; return(result); // return _abilityCommand; }