public async Task <bool> Login(User user) { try { string results = await blockchainService.InvokePostAuthentication(FlaskConsts.LoginUrl, JsonConvert.SerializeObject(user)); messageCredential checkUser = JsonConvert.DeserializeObject <messageCredential>(results); if (!string.IsNullOrEmpty(checkUser.access_token)) { string request = HyperledgerConsts.TraderQueryURL(user.username); results = await blockchainService.InvokeGet(request); thisTrader = JsonConvert.DeserializeObject <Trader>(results); return(true); } else { return(false); } } catch (HttpRequestException) { return(false); } }
public async Task <List <Package> > GetMyPackages() { try { string results = await blockchainService.InvokeGet(HyperledgerConsts.MyPackagesUrl(thisTrader.traderId)); return(JsonConvert.DeserializeObject <List <Package> >(results)); } catch (HttpRequestException) { return(null); } }
public async Task <List <NewTransfer> > GetPropertyHistory(string property) { List <NewTransfer> finalList = new List <NewTransfer>(); string results = await blockchainService.InvokeGet(HyperledgerConsts.PropertyPackageUrl(Uri.EscapeDataString(property))); List <Package> list = JsonConvert.DeserializeObject <List <Package> >(results); foreach (Package package in list) { string res2 = await blockchainService.InvokeGet(HyperledgerConsts.PackageHistoryUrl(Uri.EscapeDataString(package.PackageId))); List <NewTransfer> packageHistory = JsonConvert.DeserializeObject <List <NewTransfer> >(res2); finalList.AddRange(packageHistory); } return(finalList.OrderBy(x => x.timestamp).Reverse().ToList()); }