diff --git a/Service/DCEntityMapper/MapperFactory.cs b/Service/DCEntityMapper/MapperFactory.cs index 2179719b5..5f93eb5bb 100644 --- a/Service/DCEntityMapper/MapperFactory.cs +++ b/Service/DCEntityMapper/MapperFactory.cs @@ -298,6 +298,10 @@ namespace BeWo.Service.DCEntityMapper private static BargeldtransaktionshistoryDC_Bargeldtransaktionshistory _BargeldtransaktionshistoryDC_Bargeldtransaktionshistory; + private static WohneinheitDC_Wohneinheit _WohneinheitDC_Wohneinheit; + + private static WohneinheitBelegungDC_WohneinheitBelegung _WohneinheitBelegungDC_WohneinheitBelegung; + public static MedRecordDC_MedRecord MedRecordDC_MedRecord => _MedRecordDC_MedRecord ?? (_MedRecordDC_MedRecord = new MedRecordDC_MedRecord()); @@ -748,5 +752,11 @@ namespace BeWo.Service.DCEntityMapper public static BargeldtransaktionshistoryDC_Bargeldtransaktionshistory BargeldtransaktionshistoryDC_Bargeldtransaktionshistory => _BargeldtransaktionshistoryDC_Bargeldtransaktionshistory ?? (_BargeldtransaktionshistoryDC_Bargeldtransaktionshistory = new BargeldtransaktionshistoryDC_Bargeldtransaktionshistory()); + + public static WohneinheitDC_Wohneinheit WohneinheitDC_Wohneinheit => + _WohneinheitDC_Wohneinheit ?? (_WohneinheitDC_Wohneinheit = new WohneinheitDC_Wohneinheit()); + + public static WohneinheitBelegungDC_WohneinheitBelegung WohneinheitBelegungDC_WohneinheitBelegung => + _WohneinheitBelegungDC_WohneinheitBelegung ?? (_WohneinheitBelegungDC_WohneinheitBelegung = new WohneinheitBelegungDC_WohneinheitBelegung()); } } \ No newline at end of file diff --git a/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs b/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs new file mode 100644 index 000000000..ccf511d48 --- /dev/null +++ b/Service/DCEntityMapper/WohneinheitBelegungDC_WohneinheitBelegung.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BeWo.Data.Access; +using BeWo.Data.Entities; + +using BS.Shared; +using BS.Shared.DataContracts; + +namespace BeWo.Service.DCEntityMapper +{ + public class WohneinheitBelegungDC_WohneinheitBelegung : AbstractIDCEntityMapper + { + public virtual List MapToNewDCs(IEnumerable pEntitys, WohneinheitDC dc) + { + var lResult = new List(); + if (pEntitys != null) + { + foreach (WohneinheitBelegung iEntity in pEntitys) + { + lResult.Add(MergeWithDC(iEntity, CreateNewDC(), dc)); + } + } + return lResult; + } + + public override WohneinheitBelegungDC MergeWithDC(WohneinheitBelegung pEntity, WohneinheitBelegungDC pDataContract) + { + throw new NotImplementedException("Logik fehlt."); + + var wohneinheit = MapperFactory.WohneinheitDC_Wohneinheit.MapToNewDC(pEntity.Wohneinheit); + + return MergeWithDC(pEntity, pDataContract, wohneinheit); + } + + public WohneinheitBelegungDC MergeWithDC(WohneinheitBelegung pEntity, WohneinheitBelegungDC pDataContract, WohneinheitDC wohneinheit) + { + pDataContract.Customer = MapperFactory.CustomerDC_Customer.MapToNewDC(pEntity.Customer); + + pDataContract.Wohneinheit = wohneinheit; + + 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; + + return pDataContract; + } + + 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.Oid.Value); + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(WohneinheitBelegungDC pDC, WohneinheitBelegung pEntity) + { + if (pDC.Oid == null) + { + return false; + } + + return pDC.Oid == pEntity.Oid; + } + } +} \ No newline at end of file diff --git a/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs b/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs new file mode 100644 index 000000000..81c1742aa --- /dev/null +++ b/Service/DCEntityMapper/WohneinheitDC_Wohneinheit.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using System.Linq; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.ServiceImplementations; +using BS.Shared; +using BS.Shared.DataContracts; + +namespace BeWo.Service.DCEntityMapper +{ + public class WohneinheitDC_Wohneinheit : AbstractIDCEntityMapper + { + 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; + pDataContract.Miete = pEntity.Miete; + pDataContract.Heizung = pEntity.Heizung; + pDataContract.Strom = pEntity.Strom; + pDataContract.Betriebskosten = pEntity.Betriebskosten; + pDataContract.SonstigeKosten = pEntity.SonstigeKosten; + pDataContract.QM = pEntity.QM; + pDataContract.Baujahr = pEntity.Baujahr; + pDataContract.Mobilierung = pEntity.Mobilierung; + pDataContract.Zusatznotiz = pEntity.Zusatznotiz; + pDataContract.Stock = pEntity.Stock; + + pDataContract.Wohnheim = MapperFactory.WohnheimDC_Wohnheim.MapToNewDC(pEntity.Wohnheim); + + if (pEntity.Belegungen is object && pEntity.Belegungen.Any()) + pDataContract.Belegungen = MapperFactory.WohneinheitBelegungDC_WohneinheitBelegung.MapToNewDCs(pEntity.Belegungen, pDataContract); + + return pDataContract; + } + + 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; + pEntity.Miete = pDataContract.Miete; + pEntity.Heizung = pDataContract.Heizung; + pEntity.Strom = pDataContract.Strom; + pEntity.Betriebskosten = pDataContract.Betriebskosten; + pEntity.SonstigeKosten = pDataContract.SonstigeKosten; + pEntity.QM = pDataContract.QM; + pEntity.Baujahr = pDataContract.Baujahr; + pEntity.Mobilierung = pDataContract.Mobilierung; + pEntity.Zusatznotiz = pDataContract.Zusatznotiz; + pEntity.Stock = pDataContract.Stock; + + pEntity.Wohnheim = DAOFactory.GenericDAO.LoadByID(pDataContract.Wohnheim.WohnheimOid.Value); + + if (pEntity.Belegungen is null) + pEntity.Belegungen = new List(); + + MapperFactory.WohneinheitBelegungDC_WohneinheitBelegung.MergeWithEntitys(pDataContract.Belegungen, pEntity.Belegungen); + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(WohneinheitDC pDC, Wohneinheit pEntity) + { + if (pDC.Oid == null) + { + return false; + } + + return pDC.Oid == pEntity.Oid; + } + } +} \ No newline at end of file diff --git a/Service/Service.csproj b/Service/Service.csproj index edca4ddd1..26b8d8262 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -327,9 +327,11 @@ + +