コード例 #1
0
        public Login()
        {
            LoginCommand       = new RelayCommand(LoginAction, null);
            OpretBrugerCommand = new RelayCommand(OpretBruger, null);

            if (SingletonUsers.Instance.UserList == null)
            {
                AdminCollectionVM.AddDefaultAdmin();
            }
        }
コード例 #2
0
        //Checks if the Json file exists then adds all users to SingletonUsers.Instance.UserList
        //but if the file don't exists then it creates it and continues else if the file is empty then AdminCollectionVM.AddDefaultAdmin() gets called
        //and the Default Admin get added to SingletonUsers.Instance.UserList and get saved to the file.
        public static async void LoadUsersAsync()
        {
            PersistenceFacade.FileCreationUser();
            ObservableCollection <UserAccount> users = await PersistenceFacade.LoadUserFromJson();

            SingletonUsers.Instance.UserList.Clear();
            if (users == null)
            {
                AdminCollectionVM.AddDefaultAdmin();
            }
            else
            {
                foreach (var user in users)
                {
                    SingletonUsers.Instance.UserList.Add(user);
                }
            }
        }