public static bool InsertTest(ref TestInfo entity) { return Instance.InsertTest(ref entity); }
public static bool UpdateTest(TestInfo entity) { return Instance.UpdateTest(entity); }
// Test Info public static TestInfo GetTestInfo(DataRow dr) { TestInfo t = new TestInfo(); t.Id = GetInt(dr["ID"]); t.ClassId = GetInt(dr["ClassId"]); t.QuestionCount = GetInt(dr["QuestionCount"]); t.Title = GetString(dr["Title"]); t.Description = GetString(dr["Description"]); t.MinPassingScorePercentage = GetInt(dr["MinPassingScorePercentage"]); t.Visible = GetBool(dr["Visible"]); t.CreatedTimestamp = GetDate(dr["CreatedTimestamp"]); t.UpdatedTimestamp = GetDate(dr["UpdatedTimestamp"]); return t; }
public override bool UpdateTest(TestInfo entity) { DbCommand cmd = SqlHelpers.CreateCommand(this._connectionString); cmd.CommandText = "dbo.mon_elrn_UPDATE_TEST"; cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Id", SqlDbType.Int) { Value = entity.Id)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@ClassId", SqlDbType.Int) { Value = entity.ClassId)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Title", SqlDbType.VarChar) { Value = entity.Title)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Description", SqlDbType.VarChar) { Value = entity.Description)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@MinPassingScorePercentage", SqlDbType.Int) { Value = entity.MinPassingScorePercentage)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Visible",SqlDbType.Bit) { Value = entity.Visible)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@CreatedTimestamp", SqlDbType.SmallDateTime) { Value = entity.CreatedTimestamp)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@UpdatedTimestamp", SqlDbType.SmallDateTime) { Value = entity.UpdatedTimestamp)); int results = 0; results = SqlHelpers.ExecuteNonQuery(cmd); return Convert.ToBoolean(results); }
public override bool InsertTest(ref TestInfo entity) { DbCommand cmd = SqlHelpers.CreateCommand(this._connectionString); cmd.CommandText = "dbo.mon_elrn_INSERT_TEST"; cmd.Parameters.Add(SqlHelpers.CreateInputParam("@ClassId", SqlDbType.Int) { Value = entity.ClassId)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Title", SqlDbType.VarChar) { Value = entity.Title)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Description", SqlDbType.VarChar) { Value = entity.Description)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@MinPassingScorePercentage", SqlDbType.Int) { Value = entity.MinPassingScorePercentage)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@Visible",SqlDbType.Bit) { Value = entity.Visible)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@CreatedTimestamp", SqlDbType.SmallDateTime) { Value = entity.CreatedTimestamp)); cmd.Parameters.Add(SqlHelpers.CreateInputParam("@UpdatedTimestamp", SqlDbType.SmallDateTime) { Value = entity.UpdatedTimestamp)); int results = 0; try { results = Convert.ToInt32(SqlHelpers.ExecuteScalar(cmd)); if (results > 0) { entity.Id = results; return true; } else return false; } catch { return false; } }
public abstract bool UpdateTest(TestInfo entity);
//Test related functions public abstract bool InsertTest(ref TestInfo entity);