private static async Task GetAddressBookByKeyAsync(FirebaseRepository <AddressBook> addressBookRepo) { if (addressBookRepo == null) { throw new ArgumentNullException(nameof(addressBookRepo)); } Console.WriteLine("Get AddressBook"); var addressbookKey = Console.ReadLine(); if (null != addressbookKey) { var result = await addressBookRepo.GetByKeyAsync(addressbookKey); if (null != result) { PrintAddressBook(result); } else { Console.WriteLine("Item Not Found!"); } } else { Console.WriteLine("Invalid Key!"); } Console.WriteLine(); }
private static async Task GetLocalUserByKeyAsync(FirebaseRepository <LocalUser> localUserRepo) { if (localUserRepo == null) { throw new ArgumentNullException(nameof(localUserRepo)); } Console.WriteLine("Get LocalUser"); var localuserKey = Console.ReadLine(); if (null != localuserKey) { var result = await localUserRepo.GetByKeyAsync(localuserKey); if (null != result) { PrintLocalUser(result); } else { Console.WriteLine("Item Not Found!"); } } else { Console.WriteLine("Invalid Key!"); } Console.WriteLine(); }
public static async Task RunAsync() { const string url = "https://lumachroma.firebaseio.com"; const string auth = "x2yPyLti57aYEcKFJMHA4tMd97R7ML3jP6ZHiSs5"; var firebaseQuery = new FirebaseQuery(new FirebaseClient(url, auth)); var addressBookRepo = new FirebaseRepository <AddressBook>("AddressBook", firebaseQuery); var localUserRepo = new FirebaseRepository <LocalUser>("LocalUser", firebaseQuery); await GetAllAddresssBookAsync(addressBookRepo); await GetAllLocalUserAsync(localUserRepo); await GetAddressBookByKeyAsync(addressBookRepo); await GetLocalUserByKeyAsync(localUserRepo); await SearchAddressBookByKeyValueAsync(addressBookRepo); await SearchLocalUserByKeyValueAsync(localUserRepo); }
public static void Main(string[] args) { try { FirebaseRest.RunAsync().Wait(); FirebaseRepository.RunAsync().Wait(); Console.WriteLine("Done ......"); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Console.ReadLine(); } }
private static async Task GetAllAddresssBookAsync(FirebaseRepository <AddressBook> addressBookRepo) { if (addressBookRepo == null) { throw new ArgumentNullException(nameof(addressBookRepo)); } var addresses = await addressBookRepo.GetAllAsync(); Console.WriteLine("Addresses"); foreach (var address in addresses.Take(5)) { Console.WriteLine($"Key: {address.Key}"); PrintAddressBook(address.Object); Console.WriteLine(); } }
private static async Task GetAllLocalUserAsync(FirebaseRepository <LocalUser> localUserRepo) { if (localUserRepo == null) { throw new ArgumentNullException(nameof(localUserRepo)); } var users = await localUserRepo.GetAllAsync(); Console.WriteLine("Users"); foreach (var user in users.Take(5)) { Console.WriteLine($"Key: {user.Key}"); PrintLocalUser(user.Object); Console.WriteLine(); } }
private static async Task SearchAddressBookByKeyValueAsync(FirebaseRepository <AddressBook> addressBookRepo) { if (addressBookRepo == null) { throw new ArgumentNullException(nameof(addressBookRepo)); } Console.WriteLine("Search AddressBook"); Console.WriteLine("Key:"); var searchAddressBookKey = Console.ReadLine(); Console.WriteLine("Value:"); var searchAddressBookValue = Console.ReadLine(); if (null != searchAddressBookKey && null != searchAddressBookValue) { var searchedAddresses = await addressBookRepo.SearchByKeyValueAsync($"\"{searchAddressBookKey}\"", $"\"{searchAddressBookValue}\""); if (searchedAddresses.Any()) { foreach (var address in searchedAddresses) { Console.WriteLine($"Key: {address.Key}"); PrintAddressBook(address.Object); Console.WriteLine(); } } else { Console.WriteLine("No Item Found!"); } } else { Console.WriteLine("Invalid Key!"); } }
private static async Task SearchLocalUserByKeyValueAsync(FirebaseRepository <LocalUser> localUserRepo) { if (localUserRepo == null) { throw new ArgumentNullException(nameof(localUserRepo)); } Console.WriteLine("Search LocalUser"); Console.WriteLine("Key:"); var searchLocalUserKey = Console.ReadLine(); Console.WriteLine("Value:"); var searchLocalUserValue = Console.ReadLine(); if (null != searchLocalUserKey && null != searchLocalUserValue) { var searchedUsers = await localUserRepo.SearchByKeyValueAsync($"\"{searchLocalUserKey}\"", $"\"{searchLocalUserValue}\""); if (searchedUsers.Any()) { foreach (var user in searchedUsers) { Console.WriteLine($"Key: {user.Key}"); PrintLocalUser(user.Object); Console.WriteLine(); } } else { Console.WriteLine("No Item Found!"); } } else { Console.WriteLine("Invalid Key!"); } }