1
0
forked from s434786/DINO_SCRUM

Bug fixed with value of warehouse button

This commit is contained in:
Konrad Pierzyński 2019-01-13 17:01:56 +01:00
parent b6ca8853a8
commit fbb8fc120c
3 changed files with 34 additions and 3 deletions

View File

@ -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;
}
}
}

View File

@ -58,6 +58,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="DataModels\Fruit.cs" /> <Compile Include="DataModels\Fruit.cs" />
<Compile Include="DataModels\WarehousePrice.cs" />
<Compile Include="Views\FruitView.xaml.cs"> <Compile Include="Views\FruitView.xaml.cs">
<DependentUpon>FruitView.xaml</DependentUpon> <DependentUpon>FruitView.xaml</DependentUpon>
</Compile> </Compile>

View File

@ -69,16 +69,19 @@ namespace Magazyn
} }
} }
private string GetWarehousePrice() private WarehousePrice GetWarehousePrice()
{ {
Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all"); Task<HttpResponseMessage> response = client.GetAsync("https://sysmag.herokuapp.com/api/get-price-of-all");
while (response.IsCompleted != true) ; while (response.IsCompleted != true) ;
return response.Result.Content.ReadAsStringAsync().Result.ToString();
WarehousePrice price = JsonConvert.DeserializeObject<WarehousePrice>(response.Result.Content.ReadAsStringAsync().Result.ToString());
return price;
} }
private void Button_Click_1(object sender, RoutedEventArgs e) private void Button_Click_1(object sender, RoutedEventArgs e)
{ {
MessageBox.Show("Value of warehouse: " + GetWarehousePrice()); MessageBox.Show("Value of warehouse: " + GetWarehousePrice().Price.ToString() );
} }
} }
} }