diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 852997f87..486829103 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -19,6 +19,7 @@ using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Notifications.NotificationItems; using Tango.PPC.Jobs; using Tango.SharedUI; +using System.Data.Entity; namespace Tango.PPC.UI.ViewModels { @@ -58,11 +59,24 @@ namespace Tango.PPC.UI.ViewModels /// <summary> /// Called when the application has been started. /// </summary> - public override void OnApplicationStarted() + public async override void OnApplicationStarted() { - IsLoading = false; - LogManager.Log("Application started. Navigating to LoginView..."); - NavigationManager.NavigateTo(NavigationView.LoginView); + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + if (db.Users.Count() == 1) + { + var user = await db.Users.FirstAsync(); + LogManager.Log($"Application started. Single user detected ({user.Email}). Skipping LoginView..."); + await AuthenticationProvider.Login(user.Email, user.Password, false); + IsLoading = false; + } + else + { + LogManager.Log("Application started. Navigating to LoginView..."); + await NavigationManager.NavigateTo(NavigationView.LoginView); + IsLoading = false; + } + } } } } |
