From 5e3e55dd93e2e621e071d2c8835b31eccbd77b3c Mon Sep 17 00:00:00 2001 From: Sascha Woitschetzki Date: Wed, 21 Jun 2023 08:51:31 +0200 Subject: [PATCH] init --- .vscode/settings.json | 3 +++ Gremlin_BlazorServer/Data/DBClasses/GremlinDb.cs | 2 +- Gremlin_BlazorServer/Pages/Contacts.razor | 2 +- Gremlin_BlazorServer/Pages/Contacts.razor.cs | 3 ++- Gremlin_BlazorServer/Services/GenericController.cs | 11 +++++++++++ Gremlin_BlazorServer/appsettings.json | 4 ++-- 6 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..465f2dc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "Gremlin.sln" +} diff --git a/Gremlin_BlazorServer/Data/DBClasses/GremlinDb.cs b/Gremlin_BlazorServer/Data/DBClasses/GremlinDb.cs index 3b0134a..5bbb697 100644 --- a/Gremlin_BlazorServer/Data/DBClasses/GremlinDb.cs +++ b/Gremlin_BlazorServer/Data/DBClasses/GremlinDb.cs @@ -20,7 +20,7 @@ public class GremlinDb : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { // const string connectionString = "server=192.168.177.2;port=3306;database=regulus;user=root;password=lungretter1;SslMode=;SslCa="; // const string connectionString = "server=server0;port=3306;database=regulus;user=sascha;password=mgltoJtmmDnKJ86LltsGdw"; - const string connectionString = "server=woitschetzki.de;port=3306;database=regulus;user=sascha;password=mgltoJtmmDnKJ86LltsGdw;SslMode=;SslCa="; + const string connectionString = "server=woitschetzki.de;port=3308;database=regulus;user=sascha;password=mgltoJtmmDnKJ86LltsGdw;SslMode=;SslCa="; // optionsBuilder.LogTo(Console.WriteLine); try { diff --git a/Gremlin_BlazorServer/Pages/Contacts.razor b/Gremlin_BlazorServer/Pages/Contacts.razor index 588dd98..0a16c69 100644 --- a/Gremlin_BlazorServer/Pages/Contacts.razor +++ b/Gremlin_BlazorServer/Pages/Contacts.razor @@ -71,7 +71,7 @@ - + diff --git a/Gremlin_BlazorServer/Pages/Contacts.razor.cs b/Gremlin_BlazorServer/Pages/Contacts.razor.cs index ee4005e..a1bd001 100644 --- a/Gremlin_BlazorServer/Pages/Contacts.razor.cs +++ b/Gremlin_BlazorServer/Pages/Contacts.razor.cs @@ -64,7 +64,8 @@ public partial class Contacts { } private async Task ResolveContactAsync(Contact newContact) { - newContact.Account = await GenericController.GetAsync(a => a.AccountId.Equals(newContact.AccountId)); + newContact.Account = await GenericController.ResolveAccountById(newContact.AccountId); + if (newContact.Account != null) { newContact.NoPhoneCalls = false; newContact.EmailBounced = false; diff --git a/Gremlin_BlazorServer/Services/GenericController.cs b/Gremlin_BlazorServer/Services/GenericController.cs index dbd64af..bf9b2ac 100644 --- a/Gremlin_BlazorServer/Services/GenericController.cs +++ b/Gremlin_BlazorServer/Services/GenericController.cs @@ -329,4 +329,15 @@ public class GenericController { return 0; } } + + public async Task ResolveAccountById(uint accountId){ + try { + await using (GremlinDb gremlinDb = new()) { + return gremlinDb.Accounts.First(a => a.AccountId.Equals(accountId)); + } + } + catch { + return new Account(); + } + } } \ No newline at end of file diff --git a/Gremlin_BlazorServer/appsettings.json b/Gremlin_BlazorServer/appsettings.json index bc0de47..1d2826c 100644 --- a/Gremlin_BlazorServer/appsettings.json +++ b/Gremlin_BlazorServer/appsettings.json @@ -3,7 +3,7 @@ "DbConfig": { "DatabaseName": "Regulus", "Password": "mgltoJtmmDnKJ86LltsGdw", - "ServerName": "woitschetzki.de:3306", + "ServerName": "woitschetzki.de:3308", "UserName": "sascha" }, "Logging": { @@ -14,7 +14,7 @@ }, "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-AuthBlazorApp-3ba5a04d-8883-4edf-98d1-23755b0c5974;Trusted_Connection=True;MultipleActiveResultSets=true", - "server0": "server=woitschetzki.de;port=3306;Database=blazor;Uid=blazor;password=1FTFBh9gu4jmhmw1SMysBU", + "server0": "server=woitschetzki.de;port=3308;Database=blazor;Uid=blazor;password=1FTFBh9gu4jmhmw1SMysBU", "BlazorAuthDbConnection": "Server=(localdb)\\mssqllocaldb;Database=Gremlin_BlazorServer;Trusted_Connection=True;MultipleActiveResultSets=true" } } \ No newline at end of file