public IEnumerable<Group> GetAllGroups() { using (var conn = new DatabaseConnection()) { return null; } }
public Email GetEmail(int id) { using (var conn = new DatabaseConnection()) { return conn.SQLiteConnection.Query<Email>($"SELECT * FROM Emails WHERE Id = {id}").FirstOrDefault(); } }
public IEnumerable<Email> GetAllEmails() { using (var conn = new DatabaseConnection()) { return conn.SQLiteConnection.Query<Email>("SELECT * FROM Emails"); } }
public void SetEmail(Email email) { using (var conn = new DatabaseConnection()) { if (email.Id > 0) { // Todo? } else { conn.SQLiteConnection.Execute(@"INSERT INTO Emails ([Id], [GroupId], [From], [To], [Subject], [BodyHtml]) VALUES (@Id, @GroupId, @From, @To, @Subject, @BodyHtml)", email); } } }
public void SeedDatabase() { using (var connection = new DatabaseConnection()) { connection.SQLiteConnection.Open(); connection.SQLiteConnection.Execute(@" CREATE TABLE IF NOT EXISTS [Emails] ( [Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [GroupId] INTEGER DEFAULT 0, [From] NVARCHAR(100) NOT NULL, [To] NVARCHAR(100) NOT NULL, [Subject] NVARCHAR(200) NOT NULL, [BodyText] NVARCHAR(5000) NULL, [BodyHtml] NVARCHAR(5000) NULL )"); } }