From fbb8fc120c6da831c7f303b23e5e52e0f86579f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Pierzy=C5=84ski?= Date: Sun, 13 Jan 2019 17:01:56 +0100 Subject: [PATCH] Bug fixed with value of warehouse button --- .../Magazyn/DataModels/WarehousePrice.cs | 27 +++++++++++++++++++ Magazyn_Client/Magazyn/Magazyn.csproj | 1 + Magazyn_Client/Magazyn/MainWindow.xaml.cs | 9 ++++--- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 Magazyn_Client/Magazyn/DataModels/WarehousePrice.cs diff --git a/Magazyn_Client/Magazyn/DataModels/WarehousePrice.cs b/Magazyn_Client/Magazyn/DataModels/WarehousePrice.cs new file mode 100644 index 0000000..93c6173 --- /dev/null +++ b/Magazyn_Client/Magazyn/DataModels/WarehousePrice.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Magazyn.DataModels +{ + class WarehousePrice + { + float price; + + public float Price + { + get + { + return price; + } + } + + public WarehousePrice( [JsonProperty("price-of-all")] float price) + { + this.price = price; + } + } +} diff --git a/Magazyn_Client/Magazyn/Magazyn.csproj b/Magazyn_Client/Magazyn/Magazyn.csproj index 35fe037..14f524c 100644 --- a/Magazyn_Client/Magazyn/Magazyn.csproj +++ b/Magazyn_Client/Magazyn/Magazyn.csproj @@ -58,6 +58,7 @@ Designer + FruitView.xaml diff --git a/Magazyn_Client/Magazyn/MainWindow.xaml.cs b/Magazyn_Client/Magazyn/MainWindow.xaml.cs index a487ae9..f53a504 100644 --- a/Magazyn_Client/Magazyn/MainWindow.xaml.cs +++ b/Magazyn_Client/Magazyn/MainWindow.xaml.cs @@ -69,16 +69,19 @@ namespace Magazyn } } - private string GetWarehousePrice() + private WarehousePrice GetWarehousePrice() { Task response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all"); while (response.IsCompleted != true) ; - return response.Result.Content.ReadAsStringAsync().Result.ToString(); + + WarehousePrice price = JsonConvert.DeserializeObject(response.Result.Content.ReadAsStringAsync().Result.ToString()); + + return price; } private void Button_Click_1(object sender, RoutedEventArgs e) { - MessageBox.Show("Value of warehouse: " + GetWarehousePrice()); + MessageBox.Show("Value of warehouse: " + GetWarehousePrice().Price.ToString() ); } } }