diff --git a/BeWo/View/Controls/WohneinheitEditPopup.xaml b/BeWo/View/Controls/WohneinheitEditPopup.xaml
index dd7cafaf4..c8e264508 100644
--- a/BeWo/View/Controls/WohneinheitEditPopup.xaml
+++ b/BeWo/View/Controls/WohneinheitEditPopup.xaml
@@ -32,6 +32,7 @@
diff --git a/BeWo/View/Controls/WohneinheitEditPopup.xaml.cs b/BeWo/View/Controls/WohneinheitEditPopup.xaml.cs
index 8a278a362..d63afb48b 100644
--- a/BeWo/View/Controls/WohneinheitEditPopup.xaml.cs
+++ b/BeWo/View/Controls/WohneinheitEditPopup.xaml.cs
@@ -1,5 +1,6 @@
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
+using BS.Shared.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -106,5 +107,35 @@ namespace BeWo.View.Controls
}
}
}
+
+ private void combobox_wohnungsname_DropDownClosed(object sender, EventArgs e)
+ {
+ var vm = ViewModel.WohneinheitListVM.CurrentVM;
+
+ if (vm is null)
+ return;
+
+ var selected_item = combobox_wohnungsname.SelectedItem as string;
+
+ var selected_vm = ViewModel.WohneinheitListVM.VMList.FirstOrDefault(x => x.Wohnname == selected_item);
+
+ SetValuesFromParent(vm, selected_vm);
+ }
+
+ private void SetValuesFromParent(WohneinheitVM vm, WohneinheitVM parent_vm)
+ {
+ if (vm is null || parent_vm is null)
+ return;
+
+ if (vm.Stock.IsNullOrEmpty() && parent_vm.Stock.IsNotNullOrEmpty())
+ {
+ vm.Stock = parent_vm.Stock;
+ }
+
+ if (!vm.Baujahr.HasValue && parent_vm.Baujahr.HasValue)
+ {
+ vm.Baujahr = parent_vm.Baujahr;
+ }
+ }
}
}
diff --git a/BeWo/View/Detail/WohnheimView.xaml.cs b/BeWo/View/Detail/WohnheimView.xaml.cs
index 41d6acd86..f6f3d32b4 100644
--- a/BeWo/View/Detail/WohnheimView.xaml.cs
+++ b/BeWo/View/Detail/WohnheimView.xaml.cs
@@ -512,7 +512,6 @@ namespace BeWo.View.Detail
var vmlist = ViewModel.WohneinheitListVM;
vmlist.CurrentVM = vmlist.NewVM;
- vmlist.NewVM.Baujahr = 1900;
popup_newWohneinheit.IsOpen = true;
}
diff --git a/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs b/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs
index ea754ae2a..c2314642b 100644
--- a/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs
+++ b/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs
@@ -63,6 +63,7 @@ namespace BeWo.ViewModel.ListViewModel
public List GetWohnungsnamen() => VMList?
.Where(x => !string.IsNullOrEmpty(x.Wohnname))
+ .Where(x => !string.IsNullOrEmpty(x.Zimmername))
.Select(x => x.Wohnname)?
.Distinct()
.OrderBy(x => x)
diff --git a/BeWo/ViewModel/WohneinheitVM.cs b/BeWo/ViewModel/WohneinheitVM.cs
index 828df1d49..d26893da0 100644
--- a/BeWo/ViewModel/WohneinheitVM.cs
+++ b/BeWo/ViewModel/WohneinheitVM.cs
@@ -27,7 +27,7 @@ namespace BeWo.ViewModel
private decimal _SonstigeKosten;
private decimal _Kaution;
private decimal _QM;
- private int _Baujahr;
+ private int? _Baujahr;
private string _Mobilierung;
private string _Zusatznotiz;
private string _Stock;
@@ -86,7 +86,7 @@ namespace BeWo.ViewModel
}
}
public string Name => ToString();
- public decimal Miete
+ public decimal? Miete
{
get { return _Miete; }
set
@@ -99,7 +99,7 @@ namespace BeWo.ViewModel
FirePropertyChanged(nameof(Brutto));
}
}
- public decimal Heizung
+ public decimal? Heizung
{
get { return _Heizung; }
set
@@ -113,7 +113,7 @@ namespace BeWo.ViewModel
}
}
}
- public decimal Strom
+ public decimal? Strom
{
get { return _Strom; }
set
@@ -127,7 +127,7 @@ namespace BeWo.ViewModel
}
}
}
- public decimal Betriebskosten
+ public decimal? Betriebskosten
{
get { return _Betriebskosten; }
set
@@ -141,7 +141,7 @@ namespace BeWo.ViewModel
}
}
}
- public decimal SonstigeKosten
+ public decimal? SonstigeKosten
{
get { return _SonstigeKosten; }
set
@@ -155,7 +155,7 @@ namespace BeWo.ViewModel
}
}
}
- public decimal Kaution
+ public decimal? Kaution
{
get { return _Kaution; }
set
@@ -168,14 +168,17 @@ namespace BeWo.ViewModel
}
}
}
- public decimal Brutto
+ public decimal? Brutto
{
get
{
+ if (!Miete.HasValue & !Heizung.HasValue && !Strom.HasValue && !Betriebskosten.HasValue && !SonstigeKosten.HasValue)
+ return null;
+
return Miete + Heizung + Strom + Betriebskosten + SonstigeKosten;
}
}
- public decimal QM
+ public decimal? QM
{
get { return _QM; }
set
@@ -189,8 +192,8 @@ namespace BeWo.ViewModel
}
}
}
- public string FlacheString => QM.ToString("########0.00 qm");
- public int Baujahr
+ public string FlacheString => QM?.ToString("########0.00 qm");
+ public int? Baujahr
{
get { return _Baujahr; }
set
diff --git a/Data/Entities/Wohneinheit.cs b/Data/Entities/Wohneinheit.cs
index 43990b37c..35ee80502 100644
--- a/Data/Entities/Wohneinheit.cs
+++ b/Data/Entities/Wohneinheit.cs
@@ -36,7 +36,7 @@ namespace BeWo.Data.Entities
private decimal _SonstigeKosten;
private decimal _Kaution;
private decimal _QM;
- private int _Baujahr;
+ private int? _Baujahr;
private string _Mobilierung;
private string _Zusatznotiz;
private string _Stock;
@@ -212,7 +212,7 @@ namespace BeWo.Data.Entities
}
}
}
- public virtual int Baujahr
+ public virtual int? Baujahr
{
get
{
diff --git a/Service/DCEntityMapper/CompactWohnheimDC_Wohnheim.cs b/Service/DCEntityMapper/CompactWohnheimDC_Wohnheim.cs
index 86f1afe8f..75d0b5406 100644
--- a/Service/DCEntityMapper/CompactWohnheimDC_Wohnheim.cs
+++ b/Service/DCEntityMapper/CompactWohnheimDC_Wohnheim.cs
@@ -10,6 +10,7 @@ namespace BeWo.Service.DCEntityMapper
public override CompactWohnheimDC MergeWithDC(Wohnheim pEntity, CompactWohnheimDC pDataContract)
{
pDataContract.WohnheimOid = pEntity.Oid.Value;
+ pDataContract.Version = pEntity.Version.Value;
pDataContract.WohnheimName = pEntity.WohnheimName;
pDataContract.Strasse = pEntity.Strasse;
pDataContract.PLZ = pEntity.PLZ;
diff --git a/Shared/DataContracts/Compact/ClientPartials/CompactWohnheimDC.cs b/Shared/DataContracts/Compact/ClientPartials/CompactWohnheimDC.cs
index f4acf5b01..bdeaa022d 100644
--- a/Shared/DataContracts/Compact/ClientPartials/CompactWohnheimDC.cs
+++ b/Shared/DataContracts/Compact/ClientPartials/CompactWohnheimDC.cs
@@ -15,8 +15,6 @@ namespace BS.Shared.DataContracts.Compact
public bool SupportsActivationType { get{ return true; } set { } }
- public long Version { get; set; }
-
public SolidColorBrush FilterableBrush { get { return new SolidColorBrush(Colors.Transparent); } }
public string AddressString
diff --git a/Shared/DataContracts/Compact/CompactWohnheimDC.cs b/Shared/DataContracts/Compact/CompactWohnheimDC.cs
index 805da9299..aebd3492c 100644
--- a/Shared/DataContracts/Compact/CompactWohnheimDC.cs
+++ b/Shared/DataContracts/Compact/CompactWohnheimDC.cs
@@ -13,6 +13,9 @@ namespace BS.Shared.DataContracts.Compact
[DataMember]
public string WohnheimName { get; set; }
+ [DataMember]
+ public long Version { get; set; }
+
[DataMember]
public ActivationTypeId ActivationType { get; set; }
diff --git a/Shared/DataContracts/WohneinheitDC.cs b/Shared/DataContracts/WohneinheitDC.cs
index 8bc0402f1..7d05bd799 100644
--- a/Shared/DataContracts/WohneinheitDC.cs
+++ b/Shared/DataContracts/WohneinheitDC.cs
@@ -18,7 +18,7 @@ namespace BS.Shared.DataContracts
[DataMember] public decimal SonstigeKosten { get; set; }
[DataMember] public decimal Kaution { get; set; }
[DataMember] public decimal QM { get; set; }
- [DataMember] public int Baujahr { get; set; }
+ [DataMember] public int? Baujahr { get; set; }
[DataMember] public string Mobilierung { get; set; }
[DataMember] public string Zusatznotiz { get; set; }
[DataMember] public string Stock { get; set; }
diff --git a/Shared/Extensions/StringExtensions.cs b/Shared/Extensions/StringExtensions.cs
index c1a4795b1..c210a5bf5 100644
--- a/Shared/Extensions/StringExtensions.cs
+++ b/Shared/Extensions/StringExtensions.cs
@@ -23,6 +23,9 @@ namespace BS.Shared.Extensions
return true;
}
+ public static bool IsNotNullOrEmpty(this string pString)
+ => !IsNullOrEmpty(pString);
+
public static bool IsNullOrEmpty(this string pString)
{
return String.IsNullOrEmpty(pString);