/// <summary> /// Run query to get failed expiry logs /// </summary> /// <param name="model">ExpiryLogModel - </param> public List <ExpiryLogEntry> GetExpiryLogFailureDetails() { List <ExpiryLogEntry> expiryEmails = new List <ExpiryLogEntry>(); using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { cn.Open(); var sql = string.Format("SELECT * FROM ExpiryEmails WHERE [EmailSuccess] = {0}", 0); SqlCommand sqlCommand = new SqlCommand(sql, cn); SqlDataReader reader = sqlCommand.ExecuteReader(); while (reader.Read()) { ExpiryLogEntry model = new ExpiryLogEntry(0, null, DateTime.Now, false, null); model.Pages = reader["Pages"].ToString(); model.DateAdded = (DateTime)reader["DateAdded"]; model.EmailAddress = reader["EmailAddress"].ToString(); model.EmailSuccess = (bool)reader["EmailSuccess"]; model.Id = (int)reader["ID"]; expiryEmails.Add(model); } cn.Close(); } return(expiryEmails); }
/// <summary> /// Run SP to input the expiry email details into the database /// </summary> /// <param name="model">ExpiryLogModel - </param> public void SetExpiryLogDetails(ExpiryLogEntry model) { _db.Execute("EXEC SetExpiryLogDetails @EmailAddress, @DateAdded, @EmailSuccess, @Pages", new { model.EmailAddress, model.DateAdded, model.EmailSuccess, model.Pages }); }