1
0
forked from s442333/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>
</ApplicationDefinition>
<Compile Include="DataModels\Fruit.cs" />
<Compile Include="DataModels\WarehousePrice.cs" />
<Compile Include="Views\FruitView.xaml.cs">
<DependentUpon>FruitView.xaml</DependentUpon>
</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");
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)
{
MessageBox.Show("Value of warehouse: " + GetWarehousePrice());
MessageBox.Show("Value of warehouse: " + GetWarehousePrice().Price.ToString() );
}
}
}