private async void BtnCreate_Click(object sender, RoutedEventArgs e) { RealEstate realEstate = RealEstateFactory.addRealEstate( (Location)Enum.Parse(typeof(Location), cbxLocation.SelectedItem.ToString()), (RealEstateType)Enum.Parse(typeof(RealEstateType), cbxTypes.SelectedItem.ToString()), Convert.ToDouble(txtSquaremeter.Text, CultureInfo.InvariantCulture), Convert.ToInt32(txtRooms.Text), Convert.ToDouble(txtGardenSquaremeter.Text, CultureInfo.InvariantCulture), Convert.ToInt32(txtParkinglots.Text)); if (realEstate != null) { txtResult.Text = "Result: \n" + realEstate.ToString(); string stringPayload = await Task.Run(() => JsonConvert.SerializeObject(new RealEstateModel(realEstate.GetType().Name, realEstate.getLocation().ToString(), realEstate.getRooms(), realEstate.getSquaremeter(), realEstate.getGarden_squaremeter(), realEstate.getNum_of_parkinglots()))); StringContent httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json"); HttpResponseMessage response = await DAL.PostAsync(REST_URL, httpContent); if (response.IsSuccessStatusCode) { btnShowInList.IsEnabled = true; } else { btnShowInList.IsEnabled = false; } } else { txtResult.Text = "Not possible to create " + cbxTypes.SelectedItem.ToString() + " in " + cbxLocation.SelectedItem.ToString() + "."; } }
private void BtnShowDetails_Click(object sender, System.Windows.RoutedEventArgs e) { RealEstateModel currentModel = (RealEstateModel)dtgRealEstates.SelectedItem; if (currentModel != null) { RealEstate realEstate = RealEstateFactory.addRealEstate( (Location)Enum.Parse(typeof(Location), currentModel.Location), (RealEstateType)Enum.Parse(typeof(RealEstateType), currentModel.Type), currentModel.Squaremeter, currentModel.Rooms, currentModel.GardenSquaremeter, currentModel.NumOfParkinglots ); NavigationService.Navigate(new Details(realEstate)); } }