//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); } } }
//Checks if the Json file exists then adds all stores to SingletonStores.Instance.StoreList //but if the file don't exists then it creates it and continues else if the file is empty then StoreCollectionVM.AddStoreDummyData() gets called //and Store Dummy Data gets added to SingletonStores.Instance.StoreList and get saved to the file. public static async void LoadStoresAsync() { PersistenceFacade.FileCreationStore(); ObservableCollection <Store> stores = await PersistenceFacade.LoadStoreFromJson(); SingletonStores.Instance.StoreList.Clear(); if (stores == null) { StoreCollectionVM.AddStoreDummyData(); } else { foreach (var store in stores) { SingletonStores.Instance.StoreList.Add(store); } } }
//Gets PersistenceFacade to save SingletonUsers.Instance.UserList to the Json file. public static void SaveUsersAsync() { PersistenceFacade.SaveUserToJson(SingletonUsers.Instance.UserList); }
//Gets PersistenceFacade to save SingletonStores.Instance.StoreList to the Json file. public static void SaveStoresAsync() { PersistenceFacade.SaveStoreToJson(SingletonStores.Instance.StoreList); }