diff --git a/NoobBotDatabase/NoobBotDatabase.refactorlog b/NoobBotDatabase/NoobBotDatabase.refactorlog
new file mode 100644
index 0000000..f25b3cd
--- /dev/null
+++ b/NoobBotDatabase/NoobBotDatabase.refactorlog
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NoobBotDatabase/NoobBotDatabase.sqlproj b/NoobBotDatabase/NoobBotDatabase.sqlproj
new file mode 100644
index 0000000..dbb099c
--- /dev/null
+++ b/NoobBotDatabase/NoobBotDatabase.sqlproj
@@ -0,0 +1,119 @@
+
+
+
+
+ Debug
+ AnyCPU
+ NoobBotDatabase
+ 2.0
+ 4.1
+ {5fb2b3c8-5b8c-451e-b762-e0aa9c589005}
+ Microsoft.Data.Tools.Schema.Sql.Sql130DatabaseSchemaProvider
+ Database
+
+
+ NoobBotDatabase
+ NoobBotDatabase
+ 1033, CI
+ BySchemaAndSchemaType
+ True
+ v4.6
+ CS
+ Properties
+ False
+ True
+ True
+ True
+
+
+ bin\Release\
+ $(MSBuildProjectName).sql
+ False
+ pdbonly
+ true
+ false
+ true
+ prompt
+ 4
+
+
+ bin\Debug\
+ $(MSBuildProjectName).sql
+ false
+ true
+ full
+ false
+ true
+ true
+ prompt
+ 4
+
+
+ 11.0
+
+ True
+ 11.0
+
+
+ bin\Release\
+ $(MSBuildProjectName).sql
+ False
+ pdbonly
+ true
+ false
+ true
+ prompt
+ 4
+ x64
+
+
+ bin\Debug\
+ $(MSBuildProjectName).sql
+ false
+ true
+ full
+ false
+ true
+ true
+ prompt
+ 4
+ x64
+
+
+ bin\Release\
+ $(MSBuildProjectName).sql
+ False
+ pdbonly
+ true
+ false
+ true
+ prompt
+ 4
+ x86
+
+
+ bin\Debug\
+ $(MSBuildProjectName).sql
+ false
+ true
+ full
+ false
+ true
+ true
+ prompt
+ 4
+ x86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NoobBotDatabase/streams.sql b/NoobBotDatabase/streams.sql
new file mode 100644
index 0000000..6b2ee08
--- /dev/null
+++ b/NoobBotDatabase/streams.sql
@@ -0,0 +1,10 @@
+CREATE TABLE [dbo].[streams]
+(
+ [id] INT IDENTITY (1, 1) NOT NULL,
+ [userId] INT not null,
+ [start] DateTime NOT NULL,
+ [title] text NOT NULL,
+ [url] text
+ CONSTRAINT [PK_streams] PRIMARY KEY ([id]) NULL,
+ FOREIGN KEY ([userId]) REFERENCES [dbo].[user] ([id])
+)
diff --git a/NoobBotDatabase/user.sql b/NoobBotDatabase/user.sql
new file mode 100644
index 0000000..512cdf5
--- /dev/null
+++ b/NoobBotDatabase/user.sql
@@ -0,0 +1,7 @@
+CREATE TABLE [dbo].[user]
+(
+ [id] INT NOT NULL PRIMARY KEY,
+ [streamer] BIT NULL DEFAULT 0,
+ [name] TEXT NULL
+)
+
\ No newline at end of file
diff --git a/NoobDevBot(Stream)/libmp3lame.32.dll b/NoobDevBot(Stream)/libmp3lame.32.dll
new file mode 100644
index 0000000..719126b
Binary files /dev/null and b/NoobDevBot(Stream)/libmp3lame.32.dll differ
diff --git a/NoobDevBot(Stream)/libmp3lame.64.dll b/NoobDevBot(Stream)/libmp3lame.64.dll
new file mode 100644
index 0000000..20f23ed
Binary files /dev/null and b/NoobDevBot(Stream)/libmp3lame.64.dll differ
diff --git a/NoobDevBot.sln b/NoobDevBot.sln
index f7e9f43..443d11c 100644
--- a/NoobDevBot.sln
+++ b/NoobDevBot.sln
@@ -3,24 +3,50 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoobDevBot(Stream)", "NoobDevBot(Stream)\NoobDevBot(Stream).csproj", "{27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoobDevBot", "NoobDevBot\NoobDevBot.csproj", "{8CD55321-6BE8-4958-864F-64749D0008A5}"
EndProject
+Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "NoobBotDatabase", "NoobBotDatabase\NoobBotDatabase.sqlproj", "{5FB2B3C8-5B8C-451E-B762-E0AA9C589005}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {27A6E8B1-F7C7-4CB7-AE69-E240ED7D9971}.Release|Any CPU.Build.0 = Release|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|x64.Build.0 = Debug|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Debug|x86.Build.0 = Debug|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CD55321-6BE8-4958-864F-64749D0008A5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Release|x64.ActiveCfg = Release|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Release|x64.Build.0 = Release|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Release|x86.ActiveCfg = Release|Any CPU
+ {8CD55321-6BE8-4958-864F-64749D0008A5}.Release|x86.Build.0 = Release|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|x64.ActiveCfg = Debug|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|x64.Build.0 = Debug|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|x64.Deploy.0 = Debug|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|x86.ActiveCfg = Debug|x86
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|x86.Build.0 = Debug|x86
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Debug|x86.Deploy.0 = Debug|x86
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|x64.ActiveCfg = Release|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|x64.Build.0 = Release|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|x64.Deploy.0 = Release|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|x86.ActiveCfg = Release|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|x86.Build.0 = Release|x64
+ {5FB2B3C8-5B8C-451E-B762-E0AA9C589005}.Release|x86.Deploy.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/NoobDevBot/App.config b/NoobDevBot/App.config
index 9fed51c..458160b 100644
--- a/NoobDevBot/App.config
+++ b/NoobDevBot/App.config
@@ -1,8 +1,17 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -11,4 +20,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NoobDevBot/CommandHandler.cs b/NoobDevBot/CommandHandler.cs
new file mode 100644
index 0000000..5c07760
--- /dev/null
+++ b/NoobDevBot/CommandHandler.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace NoobDevBot
+{
+ public class CommandHandler
+ {
+ private Dictionary> mainDictionary;
+
+ public CommandHandler()
+ {
+ mainDictionary = new Dictionary>();
+ }
+
+ public Func this[string commandName]
+ {
+ get
+ {
+ Func value;
+ mainDictionary.TryGetValue(commandName, out value);
+ return value;
+ }
+ set
+ {
+ if (mainDictionary.ContainsKey(commandName))
+ mainDictionary[commandName] = value;
+ else
+ mainDictionary.Add(commandName, value);
+
+ }
+ }
+
+ public TOut Dispatch(string commandName, TIn parameter) => mainDictionary[commandName](parameter);
+
+ public bool CommandExists(string commandName) => mainDictionary.ContainsKey(commandName);
+ }
+}
diff --git a/NoobDevBot/CommandManager.cs b/NoobDevBot/CommandManager.cs
new file mode 100644
index 0000000..52d3fc9
--- /dev/null
+++ b/NoobDevBot/CommandManager.cs
@@ -0,0 +1,118 @@
+using NoobDevBot.Commands;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Args;
+using Telegram.Bot.Types;
+using Telegram.Bot.Types.Enums;
+
+namespace NoobDevBot
+{
+ public static class CommandManager
+ {
+ private static CommandHandler commandHandler;
+ private static TelegramBotClient telegramBot;
+ private static ConcurrentDictionary> commandDictionary;
+
+ public static void Initialize(TelegramBotClient telegramBot)
+ {
+ commandHandler = new CommandHandler();
+ commandDictionary = new ConcurrentDictionary>();
+ CommandManager.telegramBot = telegramBot;
+
+ commandHandler["/hello"] += (e) => hello(e);
+ commandHandler["/nextstream"] += (e) => nextStream(e);
+ commandHandler["/insertstream"] += (e) => insertStream(e);
+
+ }
+
+ public static bool Dispatch(string commandName, MessageEventArgs e)
+ {
+ if (commandName != null)
+ {
+ Console.WriteLine($"User: {e.Message.From.Username ?? e.Message.From.FirstName} try to use {commandName}");
+ commandName = commandName.ToLower();
+
+ if (commandHandler.CommandExists(commandName))
+ return commandHandler.Dispatch(commandName, e);
+ }
+ else
+ {
+ Func method;
+
+ if (commandDictionary.TryGetValue(e.Message.Chat.Id, out method))
+ return method(e);
+ }
+
+ return false;
+ }
+
+ public static async Task DispatchAsync(string commandName, MessageEventArgs e)
+ {
+ return await Task.Run(() => Dispatch(commandName, e));
+ }
+
+ private static bool deleteStream(MessageEventArgs e)
+ {
+ if (e.Message.Chat.Type == ChatType.Group || e.Message.Chat.Type == ChatType.Supergroup)
+ {
+ telegramBot.SendTextMessageAsync(e.Message.Chat.Id, "Diese Funktion ist in Gruppen nicht erlaubt");
+ return false;
+ }
+
+ var command = new DeleteStreamCommand(telegramBot, e.Message.Chat.Id);
+ if (!command.Dispatch(e))
+ return false;
+
+ command.FinishEvent += finishedCommand;
+
+ return commandDictionary.TryAdd(e.Message.Chat.Id, command.Dispatch);
+ }
+
+ private static bool insertStream(MessageEventArgs e)
+ {
+ if (e.Message.Chat.Type == ChatType.Group || e.Message.Chat.Type == ChatType.Supergroup)
+ {
+ telegramBot.SendTextMessageAsync(e.Message.Chat.Id, "Diese Funktion ist in Gruppen nicht erlaubt");
+ return false;
+ }
+
+ var command = new InsertStreamCommand(telegramBot, e.Message.Chat.Id);
+ if (!command.Dispatch(e))
+ return false;
+
+ command.FinishEvent += finishedCommand;
+
+ return commandDictionary.TryAdd(e.Message.Chat.Id, command.Dispatch);
+
+ }
+ private static bool nextStream(MessageEventArgs e)
+ {
+ var command = new NextStreamCommand(telegramBot, e.Message.Chat.Id);
+ if (!command.Dispatch(e))
+ return false;
+
+
+ return command.Dispatch(e);
+ }
+
+ private static bool hello(MessageEventArgs e)
+ {
+ var command = new HelloCommand(telegramBot, e.Message.Chat.Id);
+
+ return command.Dispatch(e);
+ }
+
+ private static void finishedCommand(object sender, MessageEventArgs e)
+ {
+ Func method;
+
+ commandDictionary.TryRemove(e.Message.Chat.Id, out method);
+
+ }
+ }
+}
diff --git a/NoobDevBot/Commands/Command.cs b/NoobDevBot/Commands/Command.cs
new file mode 100644
index 0000000..74169a6
--- /dev/null
+++ b/NoobDevBot/Commands/Command.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot.Args;
+using Telegram.Bot.Types;
+
+namespace NoobDevBot.Commands
+{
+ public class Command
+ {
+ public Func NextFunction { get; set; }
+
+ public TOut Dispatch(TParameter parameter) => NextFunction(parameter);
+
+ public delegate void FinishEventHandler(object sender, TParameter e);
+
+ public event FinishEventHandler FinishEvent;
+
+ public void RaiseFinishEvent(object sender, TParameter e) => FinishEvent?.Invoke(sender, e);
+
+ }
+}
diff --git a/NoobDevBot/Commands/DeleteStreamCommand.cs b/NoobDevBot/Commands/DeleteStreamCommand.cs
new file mode 100644
index 0000000..3482651
--- /dev/null
+++ b/NoobDevBot/Commands/DeleteStreamCommand.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Args;
+
+namespace NoobDevBot.Commands
+{
+ internal class DeleteStreamCommand
+ : Command
+ {
+ private long id;
+ private TelegramBotClient telegramBot;
+
+ public DeleteStreamCommand(TelegramBotClient telegramBot, long id)
+ {
+ this.telegramBot = telegramBot;
+ this.id = id;
+ }
+ }
+}
diff --git a/NoobDevBot/Commands/HelloCommand.cs b/NoobDevBot/Commands/HelloCommand.cs
new file mode 100644
index 0000000..0ca0b64
--- /dev/null
+++ b/NoobDevBot/Commands/HelloCommand.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Args;
+
+namespace NoobDevBot.Commands
+{
+ internal class HelloCommand
+ : Command
+ {
+ private TelegramBotClient telegramBotClient;
+ private long id;
+
+ public HelloCommand(TelegramBotClient telegramBot, long chatId)
+ {
+ NextFunction = WriteHello;
+ telegramBotClient = telegramBot;
+ id = chatId;
+ }
+
+ public bool WriteHello(MessageEventArgs e)
+ {
+ Console.WriteLine($"{e.Message.From.Username ?? e.Message.From.FirstName}: {e.Message.Text}");
+ telegramBotClient.SendTextMessageAsync(id, $"Hallo {e.Message.From.Username ?? e.Message.From.FirstName}");
+ NextFunction = null;
+ RaiseFinishEvent(this, e);
+ return true;
+ }
+ }
+}
diff --git a/NoobDevBot/Commands/InsertStreamCommand.cs b/NoobDevBot/Commands/InsertStreamCommand.cs
new file mode 100644
index 0000000..01f4be1
--- /dev/null
+++ b/NoobDevBot/Commands/InsertStreamCommand.cs
@@ -0,0 +1,91 @@
+using NoobDevBot.Commands;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Args;
+
+namespace NoobDevBot.Commands
+{
+ internal class InsertStreamCommand
+ : Command
+ {
+ private TelegramBotClient telegramBotClient;
+ private long id;
+
+ private int userId;
+ private string streamTitle;
+ private DateTime date;
+
+ public InsertStreamCommand(TelegramBotClient telegramBot, long chatId)
+ {
+ NextFunction = CheckOrInsertUser;
+ telegramBotClient = telegramBot;
+ id = chatId;
+ }
+
+ public bool CheckOrInsertUser(MessageEventArgs e)
+ {
+ if (!DatabaseManager.UserExists(e.Message.From.Id))
+ {
+ DatabaseManager.SaveNewUser(e.Message.From, false);
+ DatabaseManager.Submit();
+
+ return false;
+ }
+
+ var user = DatabaseManager.GetUser(e.Message.From.Id);
+ if (!user.streamer.Value)
+ {
+ AskUser($"Tut mir leid {e.Message.From.FirstName} du hast leider nicht genügend Rechte");
+ return false;
+ }
+
+ userId = user.id;
+
+ AskUser("Wie lautet der Titel deines Streams?");
+
+ NextFunction = GetTitleFromUser;
+
+ return true;
+ }
+
+ public void AskUser(string text) => telegramBotClient.SendTextMessageAsync(id, text);
+
+ public bool GetTitleFromUser(MessageEventArgs e)
+ {
+ streamTitle = e.Message.Text;
+
+ AskUser("Wann findet dein Stream statt?");
+
+ NextFunction = GetDateFromUser;
+
+ return true;
+ }
+
+ public bool GetDateFromUser(MessageEventArgs e)
+ {
+ if (DateTime.TryParse(e.Message.Text, out date))
+ {
+ insertStream(e);
+ NextFunction = null;
+ return true;
+ }
+
+
+ return false;
+ }
+
+ private void insertStream(MessageEventArgs e)
+ {
+ DatabaseManager.InsertNewStream(userId, date, streamTitle);
+ DatabaseManager.Submit();
+
+ AskUser("Dein Stream wurde erfolgreich eingetragen.");
+
+ RaiseFinishEvent(this, e);
+ }
+ }
+}
diff --git a/NoobDevBot/Commands/NextStreamCommand.cs b/NoobDevBot/Commands/NextStreamCommand.cs
new file mode 100644
index 0000000..0b1e360
--- /dev/null
+++ b/NoobDevBot/Commands/NextStreamCommand.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot;
+using Telegram.Bot.Args;
+
+namespace NoobDevBot.Commands
+{
+ internal class NextStreamCommand
+ : Command
+ {
+ private long id;
+ private TelegramBotClient telegramBot;
+
+ public NextStreamCommand(TelegramBotClient telegramBot, long id)
+ {
+ this.telegramBot = telegramBot;
+ this.id = id;
+
+ NextFunction = SendNextStream;
+ }
+
+ private bool SendNextStream(MessageEventArgs e)
+ {
+ var stream = DatabaseManager.GetNextStream();
+
+ string message;
+
+ if (stream != null)
+ message = $"Der Nächste Stream ist: {stream.title} am {stream.start} von {stream.user.name}";
+ else
+ message = "Leider konnte ich keinen Stream finden :(";
+
+ telegramBot.SendTextMessageAsync(id, message);
+
+ NextFunction = null;
+ RaiseFinishEvent(this, e);
+
+ return true;
+ }
+ }
+}
diff --git a/NoobDevBot/DatabaseManager.cs b/NoobDevBot/DatabaseManager.cs
new file mode 100644
index 0000000..4770cb4
--- /dev/null
+++ b/NoobDevBot/DatabaseManager.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Linq;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Telegram.Bot.Types;
+
+namespace NoobDevBot
+{
+ public static class DatabaseManager
+ {
+ static NoobBotDatabaseDataContext context;
+
+ public static void Initialize()
+ {
+ context = new NoobBotDatabaseDataContext();
+ }
+
+ public static bool UserExists(int id) => context.GetTable().Any(u => u.id == id);
+
+ public static void SaveNewUser(User user, bool streamer)
+ {
+ var table = context.GetTable();
+
+ var tempUser = new user
+ {
+ id = user.Id,
+ name = string.IsNullOrWhiteSpace(user.Username) ? user.FirstName : user.Username,
+ streamer = streamer
+ };
+
+ table.InsertOnSubmit(tempUser);
+ }
+
+ public static void InsertNewStream(int user, DateTime dateTime, string name)
+ {
+ var table = context.GetTable();
+
+ var tempStream = new streams
+ {
+ userId = user,
+ start = dateTime,
+ title = name
+ };
+
+ table.InsertOnSubmit(tempStream);
+ }
+
+ public static streams GetNextStream()
+ {
+ var table = context.GetTable();
+ return table.Where(s => s.start > DateTime.UtcNow).OrderBy(s => s.start).FirstOrDefault();
+ }
+
+ public static List GetUserStreams(int id) => GetUser(id).streams.ToList();
+
+ public static user GetUser(int id) => context.GetTable().First(u => u.id == id);
+
+ public static void Submit() => context.SubmitChanges();
+
+
+ }
+}
diff --git a/NoobDevBot/NoobBotDatabase.dbml b/NoobDevBot/NoobBotDatabase.dbml
new file mode 100644
index 0000000..ebcd76f
--- /dev/null
+++ b/NoobDevBot/NoobBotDatabase.dbml
@@ -0,0 +1,21 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/NoobDevBot/NoobBotDatabase.dbml.layout b/NoobDevBot/NoobBotDatabase.dbml.layout
new file mode 100644
index 0000000..84973e1
--- /dev/null
+++ b/NoobDevBot/NoobBotDatabase.dbml.layout
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NoobDevBot/NoobBotDatabase.designer.cs b/NoobDevBot/NoobBotDatabase.designer.cs
new file mode 100644
index 0000000..41b4a11
--- /dev/null
+++ b/NoobDevBot/NoobBotDatabase.designer.cs
@@ -0,0 +1,425 @@
+#pragma warning disable 1591
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace NoobDevBot
+{
+ using System.Data.Linq;
+ using System.Data.Linq.Mapping;
+ using System.Data;
+ using System.Collections.Generic;
+ using System.Reflection;
+ using System.Linq;
+ using System.Linq.Expressions;
+ using System.ComponentModel;
+ using System;
+
+
+ [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="NoobBotDatabase")]
+ public partial class NoobBotDatabaseDataContext : System.Data.Linq.DataContext
+ {
+
+ private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
+
+ #region Definitionen der Erweiterungsmethoden
+ partial void OnCreated();
+ partial void Insertstreams(streams instance);
+ partial void Updatestreams(streams instance);
+ partial void Deletestreams(streams instance);
+ partial void Insertuser(user instance);
+ partial void Updateuser(user instance);
+ partial void Deleteuser(user instance);
+ #endregion
+
+ public NoobBotDatabaseDataContext() :
+ base(global::NoobDevBot.Properties.Settings.Default.NoobBotDatabaseConnectionString, mappingSource)
+ {
+ OnCreated();
+ }
+
+ public NoobBotDatabaseDataContext(string connection) :
+ base(connection, mappingSource)
+ {
+ OnCreated();
+ }
+
+ public NoobBotDatabaseDataContext(System.Data.IDbConnection connection) :
+ base(connection, mappingSource)
+ {
+ OnCreated();
+ }
+
+ public NoobBotDatabaseDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
+ base(connection, mappingSource)
+ {
+ OnCreated();
+ }
+
+ public NoobBotDatabaseDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
+ base(connection, mappingSource)
+ {
+ OnCreated();
+ }
+
+ public System.Data.Linq.Table streams
+ {
+ get
+ {
+ return this.GetTable();
+ }
+ }
+
+ public System.Data.Linq.Table user
+ {
+ get
+ {
+ return this.GetTable();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.streams")]
+ public partial class streams : INotifyPropertyChanging, INotifyPropertyChanged
+ {
+
+ private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
+
+ private int _id;
+
+ private int _userId;
+
+ private System.DateTime _start;
+
+ private string _title;
+
+ private string _url;
+
+ private EntityRef _user;
+
+ #region Definitionen der Erweiterungsmethoden
+ partial void OnLoaded();
+ partial void OnValidate(System.Data.Linq.ChangeAction action);
+ partial void OnCreated();
+ partial void OnidChanging(int value);
+ partial void OnidChanged();
+ partial void OnuserIdChanging(int value);
+ partial void OnuserIdChanged();
+ partial void OnstartChanging(System.DateTime value);
+ partial void OnstartChanged();
+ partial void OntitleChanging(string value);
+ partial void OntitleChanged();
+ partial void OnurlChanging(string value);
+ partial void OnurlChanged();
+ #endregion
+
+ public streams()
+ {
+ this._user = default(EntityRef);
+ OnCreated();
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
+ public int id
+ {
+ get
+ {
+ return this._id;
+ }
+ set
+ {
+ if ((this._id != value))
+ {
+ this.OnidChanging(value);
+ this.SendPropertyChanging();
+ this._id = value;
+ this.SendPropertyChanged("id");
+ this.OnidChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_userId", DbType="Int NOT NULL")]
+ public int userId
+ {
+ get
+ {
+ return this._userId;
+ }
+ set
+ {
+ if ((this._userId != value))
+ {
+ if (this._user.HasLoadedOrAssignedValue)
+ {
+ throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
+ }
+ this.OnuserIdChanging(value);
+ this.SendPropertyChanging();
+ this._userId = value;
+ this.SendPropertyChanged("userId");
+ this.OnuserIdChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_start", DbType="DateTime NOT NULL")]
+ public System.DateTime start
+ {
+ get
+ {
+ return this._start;
+ }
+ set
+ {
+ if ((this._start != value))
+ {
+ this.OnstartChanging(value);
+ this.SendPropertyChanging();
+ this._start = value;
+ this.SendPropertyChanged("start");
+ this.OnstartChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_title", DbType="Text NOT NULL", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
+ public string title
+ {
+ get
+ {
+ return this._title;
+ }
+ set
+ {
+ if ((this._title != value))
+ {
+ this.OntitleChanging(value);
+ this.SendPropertyChanging();
+ this._title = value;
+ this.SendPropertyChanged("title");
+ this.OntitleChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_url", DbType="Text", UpdateCheck=UpdateCheck.Never)]
+ public string url
+ {
+ get
+ {
+ return this._url;
+ }
+ set
+ {
+ if ((this._url != value))
+ {
+ this.OnurlChanging(value);
+ this.SendPropertyChanging();
+ this._url = value;
+ this.SendPropertyChanged("url");
+ this.OnurlChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="user_streams", Storage="_user", ThisKey="userId", OtherKey="id", IsForeignKey=true)]
+ public user user
+ {
+ get
+ {
+ return this._user.Entity;
+ }
+ set
+ {
+ user previousValue = this._user.Entity;
+ if (((previousValue != value)
+ || (this._user.HasLoadedOrAssignedValue == false)))
+ {
+ this.SendPropertyChanging();
+ if ((previousValue != null))
+ {
+ this._user.Entity = null;
+ previousValue.streams.Remove(this);
+ }
+ this._user.Entity = value;
+ if ((value != null))
+ {
+ value.streams.Add(this);
+ this._userId = value.id;
+ }
+ else
+ {
+ this._userId = default(int);
+ }
+ this.SendPropertyChanged("user");
+ }
+ }
+ }
+
+ public event PropertyChangingEventHandler PropertyChanging;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void SendPropertyChanging()
+ {
+ if ((this.PropertyChanging != null))
+ {
+ this.PropertyChanging(this, emptyChangingEventArgs);
+ }
+ }
+
+ protected virtual void SendPropertyChanged(String propertyName)
+ {
+ if ((this.PropertyChanged != null))
+ {
+ this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[user]")]
+ public partial class user : INotifyPropertyChanging, INotifyPropertyChanged
+ {
+
+ private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
+
+ private int _id;
+
+ private System.Nullable _streamer;
+
+ private string _name;
+
+ private EntitySet _streams;
+
+ #region Definitionen der Erweiterungsmethoden
+ partial void OnLoaded();
+ partial void OnValidate(System.Data.Linq.ChangeAction action);
+ partial void OnCreated();
+ partial void OnidChanging(int value);
+ partial void OnidChanged();
+ partial void OnstreamerChanging(System.Nullable value);
+ partial void OnstreamerChanged();
+ partial void OnnameChanging(string value);
+ partial void OnnameChanged();
+ #endregion
+
+ public user()
+ {
+ this._streams = new EntitySet(new Action(this.attach_streams), new Action(this.detach_streams));
+ OnCreated();
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", DbType="Int NOT NULL", IsPrimaryKey=true)]
+ public int id
+ {
+ get
+ {
+ return this._id;
+ }
+ set
+ {
+ if ((this._id != value))
+ {
+ this.OnidChanging(value);
+ this.SendPropertyChanging();
+ this._id = value;
+ this.SendPropertyChanged("id");
+ this.OnidChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_streamer", DbType="Bit")]
+ public System.Nullable streamer
+ {
+ get
+ {
+ return this._streamer;
+ }
+ set
+ {
+ if ((this._streamer != value))
+ {
+ this.OnstreamerChanging(value);
+ this.SendPropertyChanging();
+ this._streamer = value;
+ this.SendPropertyChanged("streamer");
+ this.OnstreamerChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_name", DbType="Text", UpdateCheck=UpdateCheck.Never)]
+ public string name
+ {
+ get
+ {
+ return this._name;
+ }
+ set
+ {
+ if ((this._name != value))
+ {
+ this.OnnameChanging(value);
+ this.SendPropertyChanging();
+ this._name = value;
+ this.SendPropertyChanged("name");
+ this.OnnameChanged();
+ }
+ }
+ }
+
+ [global::System.Data.Linq.Mapping.AssociationAttribute(Name="user_streams", Storage="_streams", ThisKey="id", OtherKey="userId")]
+ public EntitySet streams
+ {
+ get
+ {
+ return this._streams;
+ }
+ set
+ {
+ this._streams.Assign(value);
+ }
+ }
+
+ public event PropertyChangingEventHandler PropertyChanging;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void SendPropertyChanging()
+ {
+ if ((this.PropertyChanging != null))
+ {
+ this.PropertyChanging(this, emptyChangingEventArgs);
+ }
+ }
+
+ protected virtual void SendPropertyChanged(String propertyName)
+ {
+ if ((this.PropertyChanged != null))
+ {
+ this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ private void attach_streams(streams entity)
+ {
+ this.SendPropertyChanging();
+ entity.user = this;
+ }
+
+ private void detach_streams(streams entity)
+ {
+ this.SendPropertyChanging();
+ entity.user = null;
+ }
+ }
+}
+#pragma warning restore 1591
diff --git a/NoobDevBot/NoobDevBot.csproj b/NoobDevBot/NoobDevBot.csproj
index 795753d..00973ea 100644
--- a/NoobDevBot/NoobDevBot.csproj
+++ b/NoobDevBot/NoobDevBot.csproj
@@ -12,6 +12,23 @@
v4.6
512
true
+
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 0.0.1.%2a
+ false
+ false
+ true
AnyCPU
@@ -31,14 +48,15 @@
TRACE
prompt
4
+ false
-
- ..\packages\NAudio.1.7.3\lib\net35\NAudio.dll
+
+ ..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll
True
-
- ..\packages\NAudio.Lame.1.0.4\lib\net20\NAudio.Lame.dll
+
+ ..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll
True
@@ -46,7 +64,9 @@
True
+
+
..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll
True
@@ -64,12 +84,39 @@
+
+
+
+
+
+
+
+
+
+ True
+ True
+ NoobBotDatabase.dbml
+
+
+ True
+ True
+ Settings.settings
+
+
+ MSLinqToSQLGenerator
+ NoobBotDatabase.designer.cs
+ Designer
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
@@ -79,7 +126,34 @@
Always
+
+
+
+
+
+ NoobBotDatabase.dbml
+
+
+
+
+ False
+ Microsoft .NET Framework 4.6 %28x86 und x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+ Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".
+
+
+