public SpellAssociatedRecords SP_GetSpellCommands(int spellId, int RuleSetID) { SpellAssociatedRecords result = new SpellAssociatedRecords(); //List<SpellCommand> _spellCommand = new List<SpellCommand>(); //List<BuffAndEffect> _BuffAndEffects = new List<BuffAndEffect>(); //List<BuffAndEffect> _selectedBuffAndEffects = new List<BuffAndEffect>(); string connectionString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value; string qry = "EXEC Spell_GetSpellCommands @SpellId = '" + spellId + "',@RuleSetID = '" + RuleSetID + "'"; using (SqlConnection connection = new SqlConnection(connectionString)) { try { connection.Open(); var data = connection.QueryMultiple(qry); result.SpellCommands = data.Read <SpellCommand>().ToList(); result.BuffAndEffectsList = data.Read <BuffAndEffect>().ToList(); result.SelectedBuffAndEffects = data.Read <BuffAndEffect>().ToList(); } catch (Exception ex1) { throw ex1; } finally { connection.Close(); } } //result.SpellCommands = _spellCommand; //result.BuffAndEffectsList = _BuffAndEffects; //result.SelectedBuffAndEffects = _selectedBuffAndEffects; return(result); }
public SpellAssociatedRecords SP_GetSpellCommands_old(int spellId, int RuleSetID) { SpellAssociatedRecords result = new SpellAssociatedRecords(); List <SpellCommand> _spellCommand = new List <SpellCommand>(); List <BuffAndEffect> _BuffAndEffects = new List <BuffAndEffect>(); List <BuffAndEffect> _selectedBuffAndEffects = new List <BuffAndEffect>(); string connectionString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value; // string qry = "EXEC Spell_GetSpellCommands @SpellId = '" + spellId + "'"; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(); SqlDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); try { connection.Open(); command = new SqlCommand("Spell_GetSpellCommands", connection); // Add the parameters for the SelectCommand. command.Parameters.AddWithValue("@SpellId", spellId); 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) { SpellCommand _spellCmd = new SpellCommand(); _spellCmd.Command = row["Command"] == DBNull.Value ? null : row["Command"].ToString(); _spellCmd.SpellId = row["SpellId"] == DBNull.Value ? 0 : Convert.ToInt32(row["SpellId"].ToString()); _spellCmd.SpellCommandId = row["SpellCommandId"] == DBNull.Value ? 0 : Convert.ToInt32(row["SpellCommandId"].ToString()); _spellCmd.IsDeleted = row["IsDeleted"] == DBNull.Value ? false : Convert.ToBoolean(row["IsDeleted"]); _spellCmd.Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(); _spellCommand.Add(_spellCmd); } } 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.SpellCommands = _spellCommand; result.BuffAndEffectsList = _BuffAndEffects; result.SelectedBuffAndEffects = _selectedBuffAndEffects; return(result); }