public IEnumerable <SuperBeingPower> GetPowers(int SuperBeingId) { var powers = new List <SuperBeingPower>(); using (SqlConnection con = new SqlConnection(_cs)) { SqlCommand cmd = new SqlCommand("Personnel.PowersRead", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); cmd.Parameters.AddWithValue("@SuperBeingId", SuperBeingId); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var power = new SuperBeingPower() { Id = Convert.ToInt32(rdr["Id"]), Name = rdr["Name"].ToString(), Description = rdr["Description"].ToString(), PowerType = rdr["PowerType"].ToString(), SuperBeingId = Convert.ToInt32(rdr["SuperBeingId"]) }; powers.Add(power); } } return(powers); }
public SuperBeingPower GetPowerById(int PowerId) { SuperBeingPower power = new SuperBeingPower(); using (SqlConnection con = new SqlConnection(_cs)) { con.Open(); SqlCommand cmd = new SqlCommand("Personnel.PowerReadByPowerId", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PowerId", PowerId)); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { power.Id = Convert.ToInt32(rdr["Id"]); power.Name = rdr["Name"].ToString(); power.Description = rdr["Description"].ToString(); power.Id = Convert.ToInt32(rdr["Id"]); power.SuperBeingId = Convert.ToInt32(rdr["SuperBeingId"]); } return(power); } }