diff options
4 files changed, 8 insertions, 13 deletions
diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs index 9d4abe5..121989c 100644 --- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs +++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs @@ -102,14 +102,14 @@ namespace ApartmentManager { InitializeComponent(); - if (UserSingleton.CurrentUser.Type == "B") navMenuItems = boardMemberMenuItems; + if (UserSingleton.Instance.CurrentUser.Type == "B") navMenuItems = boardMemberMenuItems; else navMenuItems = normalUserMenuItems; List<NavMenuItem> topNavMenuItems = navMenuItems.GetRange(0, navMenuItems.Count); - // List<NavMenuItem> bottomNavMenuItems = navMenuItems.GetRange(3, 2); + //List<NavMenuItem> bottomNavMenuItems = navMenuItems.GetRange(3, 2); NavMenuList.ItemsSource = topNavMenuItems; - // NavMenuList2.ItemsSource = bottomNavMenuItems; + //NavMenuList2.ItemsSource = bottomNavMenuItems; } public Frame AppFrame { get { return Frame; } } diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs index a91fc2b..4cf5fed 100644 --- a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs @@ -2,10 +2,6 @@ using ApartmentManager.Persistency; using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ApartmentManager.Handler { @@ -13,14 +9,13 @@ namespace ApartmentManager.Handler { public static void LogIn(string username, string password) { - string serializedUser = ApiClient.GetData($"api/Users/by-username/{username}"); if (serializedUser != null) { User user = JsonConvert.DeserializeObject<User>(serializedUser); if (user.Password == password) { - UserSingleton.CurrentUser = user; + UserSingleton.Instance.CurrentUser = user; } else throw new Exception("Wrong password!"); } @@ -30,7 +25,7 @@ namespace ApartmentManager.Handler public static void LogOut() { - UserSingleton.CurrentUser = null; + UserSingleton.Instance.CurrentUser = null; } } } diff --git a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs index aa09cf2..e5ca71e 100644 --- a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; namespace ApartmentManager.Model { - class UserSingleton + public class UserSingleton { private static UserSingleton instance; - public static User CurrentUser; + public User CurrentUser { get; set; } private UserSingleton() { } diff --git a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs index 0290053..cb8dfbb 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs @@ -69,7 +69,7 @@ namespace ApartmentManager.ViewModel { // When the navigation stack isn't restored, navigate to the first page // suppressing the initial entrance animation. - if (UserSingleton.CurrentUser.Type == "B") appShell.AppFrame.Navigate(typeof(BoardMembersPage)); + if (UserSingleton.Instance.CurrentUser.Type == "B") appShell.AppFrame.Navigate(typeof(BoardMembersPage)); else appShell.AppFrame.Navigate(typeof(ApartmentPage)); } |