From e7e0396d3ff6d78e475b571875671a8e80da03dd Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Mon, 15 Jul 2024 14:39:49 +0200 Subject: [PATCH] =?UTF-8?q?WohneinheitVM=20+=20Ebenen=20ber=C3=BCcksichtig?= =?UTF-8?q?t:=20-=20Verweise=20auf=20Parents:=20Oid=20-=20Verweise=20auf?= =?UTF-8?q?=20Childs:=20Objekte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeWo/BeWo.csproj | 2 + .../ListViewModel/WohneinheitListVM.cs | 15 + BeWo/ViewModel/WohneinheitVM.cs | 279 ++++++++++++++++++ Data/Entities/Wohneinheit.cs | 12 +- Data/Entities/WohneinheitBelegung.cs | 24 +- Data/Mappings/Wohneinheit.hbm.xml | 4 +- Data/Mappings/WohneinheitBelegung.hbm.xml | 6 +- ...hneinheitBelegungDC_WohneinheitBelegung.cs | 18 +- .../WohneinheitDC_Wohneinheit.cs | 14 +- Shared/DataContracts/DataContract.cs | 15 - Shared/DataContracts/WohneinheitBelegungDC.cs | 4 +- Shared/DataContracts/WohneinheitDC.cs | 2 +- 12 files changed, 330 insertions(+), 65 deletions(-) create mode 100644 BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs create mode 100644 BeWo/ViewModel/WohneinheitVM.cs diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 82c471f1a..b342a9929 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -1039,6 +1039,8 @@ + + diff --git a/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs b/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs new file mode 100644 index 000000000..193ae017e --- /dev/null +++ b/BeWo/ViewModel/ListViewModel/WohneinheitListVM.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; + +namespace BeWo.ViewModel.ListViewModel +{ + public class WohneinheitListVM : AbstractDCListMapperVM + { + public WohneinheitListVM(List pDCs): base(pDCs) + { + } + } +} \ No newline at end of file diff --git a/BeWo/ViewModel/WohneinheitVM.cs b/BeWo/ViewModel/WohneinheitVM.cs new file mode 100644 index 000000000..9334e50f5 --- /dev/null +++ b/BeWo/ViewModel/WohneinheitVM.cs @@ -0,0 +1,279 @@ +using BS.Shared; +using BS.Shared.DataContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.ViewModel +{ + public class WohneinheitVM : AbstractDCMapperVM + { + private long? _Oid; + private long? _Version; + private string _Notice; + + private long _WohnheimOid; + private string _Wohnname; + private string _Zimmername; + private decimal _Miete; + private decimal _Heizung; + private decimal _Strom; + private decimal _Betriebskosten; + private decimal _SonstigeKosten; + private decimal _QM; + private int _Baujahr; + private string _Mobilierung; + private string _Zusatznotiz; + private string _Stock; + private List _Belegungen; + + public WohneinheitVM(WohneinheitDC dc) : base(dc, dc.Oid == null) + { + + } + + public long WohnheimOid + { + get { return _WohnheimOid; } + set + { + if (AreDifferent(WohnheimOid, value)) + { + _WohnheimOid = value; + StoreDirtyInformation(AreDifferent(DataContract.WohnheimOid, value), nameof(WohnheimOid)); + FirePropertyChanged(nameof(WohnheimOid)); + } + } + } + + public string Wohnname + { + get { return _Wohnname; } + set + { + if (AreDifferent(Wohnname, value)) + { + _Wohnname = value; + StoreDirtyInformation(AreDifferent(DataContract.Wohnname, value), nameof(Wohnname)); + FirePropertyChanged(nameof(Wohnname)); + } + } + } + + public string Zimmername + { + get { return _Zimmername; } + set + { + if (AreDifferent(Zimmername, value)) + { + _Zimmername = value; + StoreDirtyInformation(AreDifferent(DataContract.Zimmername, value), nameof(Zimmername)); + FirePropertyChanged(nameof(Zimmername)); + } + } + } + + public decimal Miete + { + get { return _Miete; } + set + { + if (AreDifferent(Miete, value)) + { + _Miete = value; + StoreDirtyInformation(AreDifferent(DataContract.Miete, value), nameof(Miete)); + FirePropertyChanged(nameof(Miete)); + } + } + } + + public decimal Heizung + { + get { return _Heizung; } + set + { + if (AreDifferent(Heizung, value)) + { + _Heizung = value; + StoreDirtyInformation(AreDifferent(DataContract.Heizung, value), nameof(Heizung)); + FirePropertyChanged(nameof(Heizung)); + } + } + } + + public decimal Strom + { + get { return _Strom; } + set + { + if (AreDifferent(Strom, value)) + { + _Strom = value; + StoreDirtyInformation(AreDifferent(DataContract.Strom, value), nameof(Strom)); + FirePropertyChanged(nameof(Strom)); + } + } + } + + public decimal Betriebskosten + { + get { return _Betriebskosten; } + set + { + if (AreDifferent(Betriebskosten, value)) + { + _Betriebskosten = value; + StoreDirtyInformation(AreDifferent(DataContract.Betriebskosten, value), nameof(Betriebskosten)); + FirePropertyChanged(nameof(Betriebskosten)); + } + } + } + + public decimal SonstigeKosten + { + get { return _SonstigeKosten; } + set + { + if (AreDifferent(SonstigeKosten, value)) + { + _SonstigeKosten = value; + StoreDirtyInformation(AreDifferent(DataContract.SonstigeKosten, value), nameof(SonstigeKosten)); + FirePropertyChanged(nameof(SonstigeKosten)); + } + } + } + + public decimal QM + { + get { return _QM; } + set + { + if (AreDifferent(QM, value)) + { + _QM = value; + StoreDirtyInformation(AreDifferent(DataContract.QM, value), nameof(QM)); + FirePropertyChanged(nameof(QM)); + } + } + } + + public int Baujahr + { + get { return _Baujahr; } + set + { + if (AreDifferent(Baujahr, value)) + { + _Baujahr = value; + StoreDirtyInformation(AreDifferent(DataContract.Baujahr, value), nameof(Baujahr)); + FirePropertyChanged(nameof(Baujahr)); + } + } + } + + public string Mobilierung + { + get { return _Mobilierung; } + set + { + if (AreDifferent(Mobilierung, value)) + { + _Mobilierung = value; + StoreDirtyInformation(AreDifferent(DataContract.Mobilierung, value), nameof(Mobilierung)); + FirePropertyChanged(nameof(Mobilierung)); + } + } + } + + public string Zusatznotiz + { + get { return _Zusatznotiz; } + set + { + if (AreDifferent(Zusatznotiz, value)) + { + _Zusatznotiz = value; + StoreDirtyInformation(AreDifferent(DataContract.Zusatznotiz, value), nameof(Zusatznotiz)); + FirePropertyChanged(nameof(Zusatznotiz)); + } + } + } + + public string Stock + { + get { return _Stock; } + set + { + if (AreDifferent(Stock, value)) + { + _Stock = value; + StoreDirtyInformation(AreDifferent(DataContract.Stock, value), nameof(Stock)); + FirePropertyChanged(nameof(Stock)); + } + } + } + + public List Belegungen + { + get { return _Belegungen; } + set + { + if (AreDifferent(Belegungen, value)) + { + _Belegungen = value; + StoreDirtyInformation(AreDifferent(DataContract.Belegungen, value), nameof(Belegungen)); + FirePropertyChanged(nameof(Belegungen)); + } + } + } + + protected override void InitByDataContract(WohneinheitDC pDataContract) + { + _Oid = pDataContract.Oid; + _Version = pDataContract.Version; + _Notice = pDataContract.Notice; + + _Wohnname = pDataContract.Wohnname; + _Zimmername = pDataContract.Zimmername; + _Miete = pDataContract.Miete; + _Heizung = pDataContract.Heizung; + _Strom = pDataContract.Strom; + _Betriebskosten = pDataContract.Betriebskosten; + _SonstigeKosten = pDataContract.SonstigeKosten; + _QM = pDataContract.QM; + _Baujahr = pDataContract.Baujahr; + _Mobilierung = pDataContract.Mobilierung; + _Zusatznotiz = pDataContract.Zusatznotiz; + _Stock = pDataContract.Stock; + _WohnheimOid = pDataContract.WohnheimOid; + _Belegungen = pDataContract.Belegungen; + } + + protected override WohneinheitDC MapToDataContract(WohneinheitDC bDataContract, bool doCommit) + { + bDataContract.Oid = _Oid; + bDataContract.Notice = _Notice; + bDataContract.Version = _Version; + + bDataContract.Wohnname = _Wohnname; + bDataContract.Zimmername = _Zimmername; + bDataContract.Miete = _Miete; + bDataContract.Heizung = _Heizung; + bDataContract.Strom = _Strom; + bDataContract.Betriebskosten = _Betriebskosten; + bDataContract.SonstigeKosten = _SonstigeKosten; + bDataContract.QM = _QM; + bDataContract.Baujahr = _Baujahr; + bDataContract.Mobilierung = _Mobilierung; + bDataContract.Zusatznotiz = _Zusatznotiz; + bDataContract.Stock = _Stock; + bDataContract.WohnheimOid = _WohnheimOid; + bDataContract.Belegungen = _Belegungen; + + return bDataContract; + } + } +} diff --git a/Data/Entities/Wohneinheit.cs b/Data/Entities/Wohneinheit.cs index 956ddcfa5..8a7855271 100644 --- a/Data/Entities/Wohneinheit.cs +++ b/Data/Entities/Wohneinheit.cs @@ -8,7 +8,7 @@ namespace BeWo.Data.Entities { public class Wohneinheit : BeWoEntityBase { - public static string PropertyName_Wohnheim = nameof(Wohnheim); + public static string PropertyName_Wohnheim = nameof(WohnheimOid); public static string PropertyName_Wohnname = nameof(Wohnname); public static string PropertyName_Zimmername = nameof(Zimmername); public static string PropertyName_Miete = nameof(Miete); @@ -23,7 +23,7 @@ namespace BeWo.Data.Entities public static string PropertyName_Stock = nameof(Stock); public static string PropertyName_Belegungen = nameof(Belegungen); - private Wohnheim _Wohnheim; + private long _WohnheimOid; private string _Wohnname; private string _Zimmername; private decimal _Miete; @@ -43,18 +43,18 @@ namespace BeWo.Data.Entities _Tid = BS.Shared.TableID.Wohneinheit; } - public virtual Wohnheim Wohnheim + public virtual long WohnheimOid { get { - return this._Wohnheim; + return _WohnheimOid; } set { - if (this.AreDifferent(this._Wohnheim, value)) + if (AreDifferent(this._WohnheimOid, value)) { - this._Wohnheim = value; + _WohnheimOid = value; } } } diff --git a/Data/Entities/WohneinheitBelegung.cs b/Data/Entities/WohneinheitBelegung.cs index 00fbc29bd..02e07f967 100644 --- a/Data/Entities/WohneinheitBelegung.cs +++ b/Data/Entities/WohneinheitBelegung.cs @@ -8,14 +8,14 @@ namespace BeWo.Data.Entities { public class WohneinheitBelegung : BeWoEntityBase { - public static string PropertyName_Customer = nameof(Customer); - public static string PropertyName_Wohneinheit = nameof(Wohneinheit); + public static string PropertyName_Customer = nameof(CustomerOid); + public static string PropertyName_Wohneinheit = nameof(WohneinheitOid); public static string PropertyName_StartDate = nameof(StartDate); public static string PropertyName_EndDate = nameof(EndDate); public static string PropertyName_Kommentar = nameof(Kommentar); - private Customer _Customer; - private Wohneinheit _Wohneinheit; + private long _CustomerOid; + private long _WohneinheitOid; private DateTime _StartDate; private DateTime? _EndDate; private string _Kommentar; @@ -25,33 +25,33 @@ namespace BeWo.Data.Entities _Tid = BS.Shared.TableID.WohneinheitBelegung; } - public virtual Customer Customer + public virtual long CustomerOid { get { - return this._Customer; + return this._CustomerOid; } set { - if (this.AreDifferent(this._Customer, value)) + if (this.AreDifferent(this._CustomerOid, value)) { - this._Customer = value; + this._CustomerOid = value; } } } - public virtual Wohneinheit Wohneinheit + public virtual long WohneinheitOid { get { - return this._Wohneinheit; + return this._WohneinheitOid; } set { - if (this.AreDifferent(this._Wohneinheit, value)) + if (this.AreDifferent(this._WohneinheitOid, value)) { - this._Wohneinheit = value; + this._WohneinheitOid = value; } } } diff --git a/Data/Mappings/Wohneinheit.hbm.xml b/Data/Mappings/Wohneinheit.hbm.xml index 6a98c80fc..f8ffafa68 100644 --- a/Data/Mappings/Wohneinheit.hbm.xml +++ b/Data/Mappings/Wohneinheit.hbm.xml @@ -25,7 +25,9 @@ - + + + diff --git a/Data/Mappings/WohneinheitBelegung.hbm.xml b/Data/Mappings/WohneinheitBelegung.hbm.xml index c719b2a73..926bc98af 100644 --- a/Data/Mappings/WohneinheitBelegung.hbm.xml +++ b/Data/Mappings/WohneinheitBelegung.hbm.xml @@ -16,7 +16,9 @@ - - + + + \ No newline at end of file diff --git a/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs b/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs index ec24b5937..35c9b836c 100644 --- a/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs +++ b/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs @@ -13,17 +13,12 @@ namespace BeWo.Service.DCEntityMapper { public override WohneinheitBelegungDC MergeWithDC(WohneinheitBelegung pEntity, WohneinheitBelegungDC pDataContract) { - pDataContract.Customer = MapperFactory.CustomerDC_Customer.MapToNewDC(pEntity.Customer); - pDataContract.Wohneinheit = pEntity.Wohneinheit.Oid.Value; + pDataContract.CustomerOid = pEntity.CustomerOid; + pDataContract.WohneinheitOid = pEntity.WohneinheitOid; pDataContract.Oid = pEntity.Oid; - pDataContract.IsActive = pEntity.IsActive; pDataContract.Notice = pEntity.Notice; - pDataContract.InsTs = pEntity.InsTs; - pDataContract.InsUser = pEntity.InsUser; pDataContract.Version = pEntity.Version; - pDataContract.UdpUser = pEntity.UdpUser; - pDataContract.SystemEntryID = pEntity.SystemEntryID; pDataContract.StartDate = pEntity.StartDate; pDataContract.EndDate = pEntity.EndDate; pDataContract.Kommentar = pEntity.Kommentar; @@ -34,19 +29,14 @@ namespace BeWo.Service.DCEntityMapper public override WohneinheitBelegung MergeWithEntity(WohneinheitBelegungDC pDataContract, WohneinheitBelegung pEntity) { pEntity.Oid = pDataContract.Oid; - pEntity.IsActive = pDataContract.IsActive; pEntity.Notice = pDataContract.Notice; - pEntity.InsTs = pDataContract.InsTs; - pEntity.InsUser = pDataContract.InsUser; pEntity.Version = pDataContract.Version; - pEntity.UdpUser = pDataContract.UdpUser; - pEntity.SystemEntryID = pDataContract.SystemEntryID; pEntity.StartDate = pDataContract.StartDate; pEntity.EndDate = pDataContract.EndDate; pEntity.Kommentar = pDataContract.Kommentar; - pEntity.Customer = DAOFactory.GenericDAO.GetByID(pDataContract.Customer.CustomerOid.Value); - pEntity.Wohneinheit = DAOFactory.GenericDAO.GetByID(pDataContract.Wohneinheit); + pEntity.CustomerOid = pDataContract.CustomerOid; + pEntity.WohneinheitOid = pDataContract.WohneinheitOid; return pEntity; } diff --git a/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs b/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs index 9e3681e83..0cc37daac 100644 --- a/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs +++ b/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs @@ -13,13 +13,8 @@ namespace BeWo.Service.DCEntityMapper public override WohneinheitDC MergeWithDC(Wohneinheit pEntity, WohneinheitDC pDataContract) { pDataContract.Oid = pEntity.Oid; - pDataContract.IsActive = pEntity.IsActive; pDataContract.Notice = pEntity.Notice; - pDataContract.InsTs = pEntity.InsTs; - pDataContract.InsUser = pEntity.InsUser; pDataContract.Version = pEntity.Version; - pDataContract.UdpUser = pEntity.UdpUser; - pDataContract.SystemEntryID = pEntity.SystemEntryID; pDataContract.Wohnname = pEntity.Wohnname; pDataContract.Zimmername = pEntity.Zimmername; @@ -34,7 +29,7 @@ namespace BeWo.Service.DCEntityMapper pDataContract.Zusatznotiz = pEntity.Zusatznotiz; pDataContract.Stock = pEntity.Stock; - pDataContract.Wohnheim = MapperFactory.WohnheimDC_Wohnheim.MapToNewDC(pEntity.Wohnheim); + pDataContract.WohnheimOid = pEntity.WohnheimOid; if (pEntity.Belegungen is object && pEntity.Belegungen.Any()) pDataContract.Belegungen = MapperFactory.WohneinheitBelegungDC_WohneinheitBelegung.MapToNewDCs(pEntity.Belegungen); @@ -45,13 +40,8 @@ namespace BeWo.Service.DCEntityMapper public override Wohneinheit MergeWithEntity(WohneinheitDC pDataContract, Wohneinheit pEntity) { pEntity.Oid = pDataContract.Oid; - pEntity.IsActive = pDataContract.IsActive; pEntity.Notice = pDataContract.Notice; - pEntity.InsTs = pDataContract.InsTs; - pEntity.InsUser = pDataContract.InsUser; pEntity.Version = pDataContract.Version; - pEntity.UdpUser = pDataContract.UdpUser; - pEntity.SystemEntryID = pDataContract.SystemEntryID; pEntity.Wohnname = pDataContract.Wohnname; pEntity.Zimmername = pDataContract.Zimmername; @@ -66,7 +56,7 @@ namespace BeWo.Service.DCEntityMapper pEntity.Zusatznotiz = pDataContract.Zusatznotiz; pEntity.Stock = pDataContract.Stock; - pEntity.Wohnheim = DAOFactory.GenericDAO.LoadByID(pDataContract.Wohnheim.WohnheimOid.Value); + pEntity.WohnheimOid =pDataContract.WohnheimOid; if (pEntity.Belegungen is null) pEntity.Belegungen = new List(); diff --git a/Shared/DataContracts/DataContract.cs b/Shared/DataContracts/DataContract.cs index 5eb2c3d01..e13447281 100644 --- a/Shared/DataContracts/DataContract.cs +++ b/Shared/DataContracts/DataContract.cs @@ -12,25 +12,10 @@ namespace BS.Shared.DataContracts [DataMember] public long? Oid { get; set; } - [DataMember] - public ActivationTypeId IsActive { get; set; } - [DataMember] public string Notice { get; set; } - [DataMember] - public DateTime? InsTs { get; set; } - - [DataMember] - public string InsUser { get; set; } - [DataMember] public long? Version { get; set; } - - [DataMember] - public string UdpUser { get; set; } - - [DataMember] - public SystemEntryID? SystemEntryID { get; set; } } } diff --git a/Shared/DataContracts/WohneinheitBelegungDC.cs b/Shared/DataContracts/WohneinheitBelegungDC.cs index 145b3754d..f99f7c076 100644 --- a/Shared/DataContracts/WohneinheitBelegungDC.cs +++ b/Shared/DataContracts/WohneinheitBelegungDC.cs @@ -9,8 +9,8 @@ namespace BS.Shared.DataContracts { public class WohneinheitBelegungDC : DataContract { - [DataMember] public long Wohneinheit { get; set; } - [DataMember] public CustomerDC Customer { get; set; } + [DataMember] public long WohneinheitOid { get; set; } + [DataMember] public long CustomerOid { get; set; } [DataMember] public DateTime StartDate { get; set; } [DataMember] public DateTime? EndDate { get; set; } [DataMember] public string Kommentar { get; set; } diff --git a/Shared/DataContracts/WohneinheitDC.cs b/Shared/DataContracts/WohneinheitDC.cs index ed0874e26..caf18722a 100644 --- a/Shared/DataContracts/WohneinheitDC.cs +++ b/Shared/DataContracts/WohneinheitDC.cs @@ -9,7 +9,7 @@ namespace BS.Shared.DataContracts { public class WohneinheitDC : DataContract { - [DataMember] public WohnheimDC Wohnheim { get; set; } + [DataMember] public long WohnheimOid { get; set; } [DataMember] public string Wohnname { get; set; } [DataMember] public string Zimmername { get; set; } [DataMember] public decimal Miete { get; set; }