public static ChatCommand GetCommandFromDBAtRow(int rowNumber)
        {
            Func <SqlDataReader, ChatCommand> getCommandParameters = (reader) =>
            {
                ChatCommand command = new ChatCommand(reader["TriggerText"].ToString(),
                                                      reader["ResponseText"].ToString(),
                                                      reader["ChannelName"].ToString(),
                                                      reader["IsUniversal"] as bool? ?? false,
                                                      reader["MustBeExact"] as bool? ?? false,
                                                      reader["WhisperResponse"] as bool? ?? false,
                                                      reader["SubscriberOnly"] as bool? ?? false,
                                                      reader["ModeratorOnly"] as bool? ?? false,
                                                      reader["BroadcasterOnly"] as bool? ?? false);
                return(command);
            };

            return(Database.GetEntryAt("COMMANDS", rowNumber, getCommandParameters));
        }
        public static void AddCommandToDB(ChatCommand command)
        {
            string tableName      = "COMMANDS";
            string columnNames    = "TriggerText, ResponseText, ChannelName, IsUniversal, MustBeExact, WhisperResponse, SubscriberOnly, ModeratorOnly";
            string parameterNames = @"@triggerText, @responseText, @channelName, @isUniversal, @mustBeExact, @whisperResponse, @subscriberOnly, @moderatorOnly";

            Action <SqlCommand> addParameters = (insertCommand) =>
            {
                insertCommand.Parameters.AddWithValue("@triggerText", command.TriggerText);
                insertCommand.Parameters.AddWithValue("@responseText", command.responseText);
                insertCommand.Parameters.AddWithValue("@channelName", command.ChannelName);
                insertCommand.Parameters.AddWithValue("@isUniversal", command.IsUniversal);
                insertCommand.Parameters.AddWithValue("@mustBeExact", command.MustBeExact);
                insertCommand.Parameters.AddWithValue("@whisperResponse", command.WhisperResponse);
                insertCommand.Parameters.AddWithValue("@subscriberOnly", command.SubscriberOnly);
                insertCommand.Parameters.AddWithValue("@moderatorOnly", command.ModeratorOnly);
                insertCommand.Parameters.AddWithValue("@moderatorOnly", command.BroadcasterOnly);
            };

            Database.InsertEntry(tableName, columnNames, parameterNames, addParameters);
        }
Ejemplo n.º 3
0
 public static ChatCommand GetCommandFromDBAtRow(int rowNumber)
 {
     Func<SqlDataReader, ChatCommand> getCommandParameters = (reader) =>
     {
         ChatCommand command = new ChatCommand(reader["TriggerText"].ToString(),
             reader["ResponseText"].ToString(),
             reader["ChannelName"].ToString(),
             reader["IsUniversal"] as bool? ?? false,
             reader["MustBeExact"] as bool? ?? false,
             reader["WhisperResponse"] as bool? ?? false,
             reader["SubscriberOnly"] as bool? ?? false,
             reader["ModeratorOnly"] as bool? ?? false,
             reader["BroadcasterOnly"] as bool? ?? false);
     return command;
     };
     return Database.GetEntryAt("COMMANDS", rowNumber, getCommandParameters);
 }
Ejemplo n.º 4
0
        public static void AddCommandToDB(ChatCommand command)
        {
            string tableName = "COMMANDS";
            string columnNames = "TriggerText, ResponseText, ChannelName, IsUniversal, MustBeExact, WhisperResponse, SubscriberOnly, ModeratorOnly";
            string parameterNames = @"@triggerText, @responseText, @channelName, @isUniversal, @mustBeExact, @whisperResponse, @subscriberOnly, @moderatorOnly";

            Action<SqlCommand> addParameters = (insertCommand) =>
            {
                insertCommand.Parameters.AddWithValue("@triggerText", command.TriggerText);
                insertCommand.Parameters.AddWithValue("@responseText", command.responseText);
                insertCommand.Parameters.AddWithValue("@channelName", command.ChannelName);
                insertCommand.Parameters.AddWithValue("@isUniversal", command.IsUniversal);
                insertCommand.Parameters.AddWithValue("@mustBeExact", command.MustBeExact);
                insertCommand.Parameters.AddWithValue("@whisperResponse", command.WhisperResponse);
                insertCommand.Parameters.AddWithValue("@subscriberOnly", command.SubscriberOnly);
                insertCommand.Parameters.AddWithValue("@moderatorOnly", command.ModeratorOnly);
                insertCommand.Parameters.AddWithValue("@moderatorOnly", command.BroadcasterOnly);
            };

            Database.InsertEntry(tableName, columnNames, parameterNames, addParameters);
        }