Ejemplo n.º 1
0
        public static void AddQuoteToDB(Quote quote)
        {
            string tableName = "QUOTES";
            string columnNames = "QuoteText, ChannelName, AddedBy, DateAdded";
            string parameterNames = @"@quoteText, @channelName, @addedBy, @dateAdded";

            Action<SqlCommand> addParameters = (insertCommand) =>
            {
                insertCommand.Parameters.AddWithValue("@quoteText", quote.QuoteText);
                insertCommand.Parameters.AddWithValue("@channelName", quote.Channel);
                insertCommand.Parameters.AddWithValue("@addedBy", quote.AddedBy);
                insertCommand.Parameters.AddWithValue("@dateAdded", quote.DateAdded);
            };

            Database.InsertEntry(tableName, columnNames, parameterNames, addParameters);
        }
Ejemplo n.º 2
0
 public static Quote GetQuoteFromDBAtRow(int rowNumber)
 {
     Func<SqlDataReader, Quote> getQuoteParameters = (reader) =>
     {
         Quote quote = new Quote(reader["QuoteText"].ToString(),
             reader["ChannelName"].ToString(),
             reader["AddedBy"].ToString(),
             (DateTime)reader["DateAdded"]);
         return quote;
     };
     return Database.GetEntryAt("QUOTES", rowNumber, getQuoteParameters);
 }