public StorageAgeLimit GetSQlData(string stringConnection, int _Id) { SqlConnection conn = new SqlConnection(stringConnection); conn.Open(); Logger logger = LogManager.GetCurrentClassLogger(); logger.Info("Inside"); StorageAgeLimit ageLimit = new StorageAgeLimit(); string sqlGetCmd = @"select Age_Limit from AgeLimit where IdAgeLimit = @_IdAgeLimit"; SqlCommand cmd = new SqlCommand(sqlGetCmd, conn); cmd.Parameters.AddWithValue("_IdAgeLimit", _Id); SqlDataReader rdb = cmd.ExecuteReader(); rdb.Read(); ageLimit.IdAgeLimit = _Id; ageLimit.Age_Limit = (string)GetUnoSQlValue(rdb,"Age_Limit"); if (conn != null) { conn.Close(); conn.Dispose(); } else { logger.Warn("SQlConnection not close"); } return ageLimit; }
public void TestStorageAgeLimit() { //Arrage IRepositoryAgeLimit test = new RepositoryAgeLimit(); StorageAgeLimit ob = new StorageAgeLimit(); //Act ob = test.GetSQlData(stringConnection, 1); //Assert Assert.AreEqual("0+", ob.Age_Limit); }
public void SetSQlData(string stringConnection, StorageAgeLimit ageLimit) { SqlConnection conn = new SqlConnection(stringConnection); conn.Open(); Logger logger = LogManager.GetCurrentClassLogger(); logger.Info("Inside"); string strInsert = @"insert into AgeLimit (Age_Limit) values('@_Age_Limit')"; SqlCommand cmd = new SqlCommand(strInsert, conn); cmd.Parameters.AddWithValue("@_Age_Limit", ageLimit.Age_Limit); if (conn != null) { conn.Close(); conn.Dispose(); logger.Info("SQlConnection close"); } else { logger.Warn("SQlConnection not close"); } cmd.ExecuteNonQuery(); }