private async void HandleNoteCommand(string[] parameters, SLRuntimeEventArgs e) { if (parameters.Length >= 2) { string option = parameters[1]; DBWorker dbWorker = new DBWorker(cDatabaseFolderPath + e.user + ".sqlite"); dbWorker.Open(); if (option.Equals("-l")) { List <DBNotesEntry> dbNotesEntriesList = dbWorker.SelectNotes(); if (dbNotesEntriesList.Count > 0) { foreach (DBNotesEntry dbNoteEntry in dbNotesEntriesList) { StringBuilder message = new StringBuilder(""); message.Append("Id: "); message.Append(dbNoteEntry.id); message.Append("\n"); message.Append("Note: "); //string normalized = SLNormalizer.Normalize(dbNoteEntry.note); //message.Append(normalized); message.Append(dbNoteEntry.note); message.Append("\n"); await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true, true); } } else { string message = "There is 0 notes found in database"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true); } } else if (option.Equals("-d")) { if (parameters.Length >= 3) { string id = parameters[2]; if (dbWorker.DeleteNote(id) > 0) { string message = "Note " + id + " was deleted"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true); } else { string message = "Note was not deleted or there is no note to delete"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true); } } } else if (option.Equals("-da")) { int deletedNotesCount = dbWorker.DeleteAllNotes(); if (deletedNotesCount > 0) { string message = deletedNotesCount + " notes was deleted"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true); } else { string message = "Notes was not deleted or there is no notes to delete"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true); } } else { string note = e.text.Substring((cNoteCommand + " ").Length); if ((dbWorker.InsertNote(SLNormalizer.Denormalize(note))) > 0) { string message = "Note was added"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message.ToString()), true); } else { string message = "For some reason note was not inserted"; await slWebApiClient.ChatPostMessageAsync(e.channel, slWebApiClient.WrapWithConsoles(message), true); } } dbWorker.Close(); } }