diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-26 13:37:11 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-26 13:37:11 +0200 |
| commit | 10a9435c7fece43c588addb744952d92596a8f5b (patch) | |
| tree | f3a05a18a437b64f8876cf193497eaa054d7dc57 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels | |
| parent | 0821e00982f13f234c4e83def85b2d49a5fed9b8 (diff) | |
| download | Tango-10a9435c7fece43c588addb744952d92596a8f5b.tar.gz Tango-10a9435c7fece43c588addb744952d92596a8f5b.zip | |
Implemented single user mode on PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
| -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; + } + } } } } |
