Entity - 2 Objekt Verweise
DC - nur Wohnheim -> Wohneinheit Vm - 2 Objekt Verweise
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
mc:Ignorable="d"
|
||||
Width="500"
|
||||
StaysOpen="True" Placement="MousePoint" Opened="Popup_Opened">
|
||||
<Border Background="White" Padding="3" BorderThickness="1" BorderBrush="Gray">
|
||||
<Border Background="White" Padding="3" BorderThickness="1" BorderBrush="Gray" VerticalAlignment="Stretch">
|
||||
<GroupBox x:Name="groupbox_newWohneinheit" Header="Wohneinheit erstellen" Style="{StaticResource ObjectEditGroupBox}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
||||
@@ -327,6 +327,16 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Button Click="Button_NewWohneinheit_Click" Content="Wohneinheit hinzufügen" HorizontalAlignment="Left" Margin="3"/>
|
||||
<dxg:GridControl Grid.Row="1" DataSource="{Binding WohneinheitListVM.VMList}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.ColumnSpan="2">
|
||||
<dxg:GridColumn x:Name="ColumnButtons" AllowEditing="False" Width="Auto" FieldName="ReportLink" Header=" ">
|
||||
<dxg:GridColumn.DisplayTemplate>
|
||||
<ControlTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="1">
|
||||
<Button Click="btn_details_Click" Content="¥" Padding="0" Margin="1" ToolTip="Details anzeigen" Foreground="#FFFFFF" FontSize="11" FontFamily="Webdings" x:Name="btn_details" Height="18" Width="20" VerticalAlignment="Center" />
|
||||
<Button Click="btn_delete_Click" Content="r" Padding="0" Margin="1" ToolTip="Löschen" Foreground="#FF0000" FontSize="11" FontFamily="Webdings" x:Name="btn_delete" Height="18" Width="20" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</dxg:GridColumn.DisplayTemplate>
|
||||
</dxg:GridColumn>
|
||||
<dxg:GridColumn ReadOnly="True" AllowEditing="False" FieldName="Oid" Header="Nr." />
|
||||
<dxg:GridColumn ReadOnly="True" AllowEditing="False" FieldName="Wohnname" Header="Wohnungsname" />
|
||||
<dxg:GridColumn ReadOnly="True" AllowEditing="False" FieldName="Zimmername" Header="Zimmername" />
|
||||
@@ -348,8 +358,8 @@
|
||||
<dxe:TextEditSettings DisplayFormat="c" Mask="c" MaskType="Numeric" HorizontalContentAlignment="Right"></dxe:TextEditSettings>
|
||||
</dxg:GridColumn.EditSettings>
|
||||
</dxg:GridColumn>
|
||||
<dxg:GridColumn ReadOnly="True" AllowEditing="False" FieldName="Mobilierung" Header="Möbilierung" />
|
||||
<dxg:GridColumn ReadOnly="True" AllowEditing="False" FieldName="Zusatznotiz" Header="Notiz" />
|
||||
<dxg:GridColumn FieldName="Mobilierung" Header="Möbilierung" />
|
||||
<dxg:GridColumn FieldName="Zusatznotiz" Header="Notiz" />
|
||||
<dxg:GridControl.View>
|
||||
<dxg:TableView NavigationStyle="Cell" BestFitModeOnSourceChange="AllRows" BestFitMode="AllRows"/>
|
||||
</dxg:GridControl.View>
|
||||
|
||||
@@ -452,10 +452,19 @@ namespace BeWo.View.Detail
|
||||
private void Button_NewWohneinheit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.WohneinheitListVM.NewVM.Baujahr = 1900;
|
||||
ViewModel.WohneinheitListVM.NewVM.WohnheimOid = ViewModel.DataContract.WohnheimOid ?? 0;
|
||||
|
||||
//popup_newWohneinheit.ViewModel = ViewModel;
|
||||
popup_newWohneinheit.IsOpen = true;
|
||||
}
|
||||
|
||||
private void btn_details_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btn_delete_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,15 @@ using System.Linq;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
public class WohneinheitListVM : AbstractDCListMapperVM<WohneinheitDC, WohneinheitVM>
|
||||
{
|
||||
public WohneinheitListVM(List<WohneinheitDC> pDCs): base(pDCs)
|
||||
public WohneinheitListVM(List<WohneinheitDC> pDCs, WohnheimVM parentVm): base(pDCs)
|
||||
{
|
||||
|
||||
VMList.DoForEach(x => x.Wohnheim = parentVm);
|
||||
}
|
||||
|
||||
public WohneinheitVM CurrentVM => EditVM ?? NewVM;
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace BeWo.ViewModel
|
||||
private long? _Version;
|
||||
private string _Notice;
|
||||
|
||||
private long _WohnheimOid;
|
||||
private long? _WohnheimOid;
|
||||
private WohnheimVM _Wohnheim;
|
||||
private string _Wohnname;
|
||||
private string _Zimmername;
|
||||
private decimal _Miete;
|
||||
@@ -36,22 +37,20 @@ namespace BeWo.ViewModel
|
||||
|
||||
}
|
||||
|
||||
public long WohnheimOid
|
||||
public long? Oid => _Oid;
|
||||
|
||||
public WohnheimVM Wohnheim
|
||||
{
|
||||
get { return _WohnheimOid; }
|
||||
get { return _Wohnheim; }
|
||||
set
|
||||
{
|
||||
if (AreDifferent(WohnheimOid, value))
|
||||
{
|
||||
_WohnheimOid = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.WohnheimOid, value), nameof(WohnheimOid));
|
||||
FirePropertyChanged(nameof(WohnheimOid));
|
||||
}
|
||||
if (!AreDifferent(Wohnheim, value))
|
||||
return;
|
||||
|
||||
_Wohnheim = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long? Oid => _Oid;
|
||||
|
||||
public string Wohnname
|
||||
{
|
||||
get { return _Wohnname; }
|
||||
@@ -268,7 +267,6 @@ namespace BeWo.ViewModel
|
||||
_Mobilierung = pDataContract.Mobilierung;
|
||||
_Zusatznotiz = pDataContract.Zusatznotiz;
|
||||
_Stock = pDataContract.Stock;
|
||||
_WohnheimOid = pDataContract.WohnheimOid;
|
||||
_Belegungen = pDataContract.Belegungen;
|
||||
}
|
||||
protected override WohneinheitDC MapToDataContract(WohneinheitDC bDataContract, bool doCommit)
|
||||
@@ -290,7 +288,6 @@ namespace BeWo.ViewModel
|
||||
bDataContract.Mobilierung = _Mobilierung;
|
||||
bDataContract.Zusatznotiz = _Zusatznotiz;
|
||||
bDataContract.Stock = _Stock;
|
||||
bDataContract.WohnheimOid = _WohnheimOid;
|
||||
bDataContract.Belegungen = _Belegungen;
|
||||
|
||||
return bDataContract;
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace BeWo.ViewModel
|
||||
|
||||
WohnheimEmployeeRelations = VMFactory.CreateWohnheimEmployeeRelationListVM(pDataContract.RelatedEmployees ?? (pDataContract.RelatedEmployees = new List<WohnheimEmployeeRelationDC>()));
|
||||
WohnheimCustomerRelations = VMFactory.CreateWohnheimCustomerRelationListVM(pDataContract.RelatedCustomers ?? (pDataContract.RelatedCustomers = new List<WohnheimCustomerRelationDC>()));
|
||||
WohneinheitListVM = new WohneinheitListVM(pDataContract.Wohneinheiten ?? (pDataContract.Wohneinheiten = new List<WohneinheitDC>()));
|
||||
WohneinheitListVM = new WohneinheitListVM(pDataContract.Wohneinheiten ?? (pDataContract.Wohneinheiten = new List<WohneinheitDC>()), this);
|
||||
}
|
||||
|
||||
protected override WohnheimDC MapToDataContract(WohnheimDC pDataContract, bool doCommit)
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace BeWo.Data.Entities
|
||||
{
|
||||
public class Wohneinheit : BeWoEntityBase
|
||||
{
|
||||
public static string PropertyName_Wohnheim = nameof(WohnheimOid);
|
||||
public static string PropertyName_Wohnheim = nameof(Wohnheim);
|
||||
//public static string PropertyName_WohnheimOid = nameof(WohnheimOid);
|
||||
public static string PropertyName_Wohnname = nameof(Wohnname);
|
||||
public static string PropertyName_Zimmername = nameof(Zimmername);
|
||||
public static string PropertyName_Miete = nameof(Miete);
|
||||
@@ -24,7 +25,8 @@ namespace BeWo.Data.Entities
|
||||
public static string PropertyName_Stock = nameof(Stock);
|
||||
public static string PropertyName_Belegungen = nameof(Belegungen);
|
||||
|
||||
private long _WohnheimOid;
|
||||
private Wohnheim _Wohnheim;
|
||||
//private long? _WohnheimOid;
|
||||
private string _Wohnname;
|
||||
private string _Zimmername;
|
||||
private decimal _Miete;
|
||||
@@ -45,21 +47,36 @@ namespace BeWo.Data.Entities
|
||||
_Tid = BS.Shared.TableID.Wohneinheit;
|
||||
}
|
||||
|
||||
public virtual long WohnheimOid
|
||||
public virtual Wohnheim Wohnheim
|
||||
{
|
||||
get
|
||||
{
|
||||
return _WohnheimOid;
|
||||
return _Wohnheim;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(this._WohnheimOid, value))
|
||||
if (AreDifferent(this._Wohnheim, value))
|
||||
{
|
||||
_WohnheimOid = value;
|
||||
_Wohnheim = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
//public virtual long? WohnheimOid
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return _WohnheimOid;
|
||||
// }
|
||||
|
||||
// set
|
||||
// {
|
||||
// if (AreDifferent(this._WohnheimOid, value))
|
||||
// {
|
||||
// _WohnheimOid = value;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public virtual string Wohnname
|
||||
{
|
||||
get
|
||||
|
||||
@@ -26,9 +26,8 @@
|
||||
<property name="Mobilierung"/>
|
||||
<property name="Zusatznotiz"/>
|
||||
<property name="Stock"/>
|
||||
|
||||
<property name="WohnheimOid"/>
|
||||
<!--<many-to-one name="Wohnheim" column="WohnheimOid" class="BeWo.Data.Entities.Wohnheim,BeWo.Data" cascade="all-delete-orphan" fetch="join"/>-->
|
||||
<!--<property name="WohnheimOid" insert="false" update="false"/>-->
|
||||
<!--<many-to-one name="Wohnheim" column="WohnheimOid" class="BeWo.Data.Entities.Wohnheim,BeWo.Data" cascade="none" fetch="join"/>-->
|
||||
<bag name="Belegungen" table="Wohneinheitbelegung" generic="true" cascade="all-delete-orphan" batch-size="250">
|
||||
<key column="WohneinheitOid" />
|
||||
<one-to-many class="BeWo.Data.Entities.WohneinheitBelegung,BeWo.Data" />
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
<key column="WohnheimOid" />
|
||||
<one-to-many class="BeWo.Data.Entities.Customer2Wohnheim,BeWo.Data" />
|
||||
</bag>
|
||||
<bag name="Wohneinheiten" table="Wohneinheit" generic="true" cascade="all-delete-orphan" batch-size="250">
|
||||
<key column="WohnheimOid" />
|
||||
<bag name="Wohneinheiten" table="Wohneinheit" inverse="true" generic="true" cascade="all-delete-orphan" batch-size="250">
|
||||
<key column="WohnheimOid" not-null="true"/>
|
||||
<one-to-many class="BeWo.Data.Entities.Wohneinheit,BeWo.Data" />
|
||||
</bag>
|
||||
</class>
|
||||
|
||||
@@ -23,6 +23,7 @@ CREATE TABLE `wohneinheit` (
|
||||
`Zusatznotiz` varchar(1024) DEFAULT NULL,
|
||||
`Stock` varchar(256) DEFAULT NULL,
|
||||
PRIMARY KEY (`Oid`),
|
||||
CONSTRAINT `FK_WOHNEINHEIT_WOHNHEIM` FOREIGN KEY (`WohnheimOid`) REFERENCES `Wohnheim` (`Oid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `wohneinheitbelegung` (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BeWo.Data.Entities;
|
||||
@@ -38,7 +39,7 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
foreach (var iToMerge in lToMerge)
|
||||
{
|
||||
this.MergeWithEntity(iToMerge.DataContract, iToMerge.Entity);
|
||||
MergeWithEntity(iToMerge.DataContract, iToMerge.Entity);
|
||||
}
|
||||
|
||||
// add new
|
||||
|
||||
@@ -1,15 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
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;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class WohneinheitDC_Wohneinheit : AbstractIDCEntityMapper<Wohneinheit, WohneinheitDC>
|
||||
{
|
||||
public override List<WohneinheitDC> MapToNewDCs(IEnumerable<Wohneinheit> pEntitys)
|
||||
{
|
||||
throw new NotImplementedException("Falscher Aufruf.");
|
||||
}
|
||||
|
||||
public List<WohneinheitDC> MapToNewDCs(IEnumerable<Wohneinheit> pEntitys, WohnheimDC parent)
|
||||
{
|
||||
var res = base.MapToNewDCs(pEntitys);
|
||||
|
||||
// res.DoForEach(x => x.Wohnheim = parent);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void MergeWithEntitys(IList<WohneinheitDC> pDataContractList, IList<Wohneinheit> pEntityList)
|
||||
{
|
||||
throw new NotImplementedException("Falscher Aufruf.");
|
||||
}
|
||||
|
||||
public void MergeWithEntitys(IList<WohneinheitDC> pDataContractList, IList<Wohneinheit> pEntityList, Wohnheim parent)
|
||||
{
|
||||
base.MergeWithEntitys(pDataContractList, pEntityList);
|
||||
|
||||
pEntityList.DoForEach(x => x.Wohnheim = parent);
|
||||
}
|
||||
|
||||
public override WohneinheitDC MergeWithDC(Wohneinheit pEntity, WohneinheitDC pDataContract)
|
||||
{
|
||||
pDataContract.Oid = pEntity.Oid;
|
||||
@@ -30,8 +58,6 @@ namespace BeWo.Service.DCEntityMapper
|
||||
pDataContract.Zusatznotiz = pEntity.Zusatznotiz;
|
||||
pDataContract.Stock = pEntity.Stock;
|
||||
|
||||
pDataContract.WohnheimOid = pEntity.WohnheimOid;
|
||||
|
||||
if (pEntity.Belegungen is object && pEntity.Belegungen.Any())
|
||||
pDataContract.Belegungen = MapperFactory.WohneinheitBelegungDC_WohneinheitBelegung.MapToNewDCs(pEntity.Belegungen);
|
||||
|
||||
@@ -58,8 +84,6 @@ namespace BeWo.Service.DCEntityMapper
|
||||
pEntity.Zusatznotiz = pDataContract.Zusatznotiz;
|
||||
pEntity.Stock = pDataContract.Stock;
|
||||
|
||||
pEntity.WohnheimOid =pDataContract.WohnheimOid;
|
||||
|
||||
if (pEntity.Belegungen is null)
|
||||
pEntity.Belegungen = new List<WohneinheitBelegung>();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using BeWo.Data.Entities;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.Extensions;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
@@ -12,10 +13,6 @@ namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public override WohnheimDC MergeWithDC(Wohnheim pEntity, WohnheimDC pDataContract)
|
||||
{
|
||||
pDataContract.RelatedEmployees = MapperFactory.EmployeeWohnheimRelDC_Employee2WohnheimMapper.MapToNewDCs(pEntity.Employee2WohnheimList);
|
||||
pDataContract.RelatedCustomers = MapperFactory.CustomerWohnheimRelDC_Customer2WohnheimMapper.MapToNewDCs(pEntity.Customer2WohnheimList);
|
||||
pDataContract.Wohneinheiten = MapperFactory.WohneinheitDC_Wohneinheit.MapToNewDCs(pEntity.Wohneinheiten);
|
||||
|
||||
pDataContract.WohnheimOid = pEntity.Oid;
|
||||
pDataContract.WohnheimName = pEntity.WohnheimName;
|
||||
pDataContract.Strasse = pEntity.Strasse;
|
||||
@@ -31,6 +28,10 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
pDataContract.ActivationType = pEntity.IsActive;
|
||||
|
||||
pDataContract.RelatedEmployees = MapperFactory.EmployeeWohnheimRelDC_Employee2WohnheimMapper.MapToNewDCs(pEntity.Employee2WohnheimList);
|
||||
pDataContract.RelatedCustomers = MapperFactory.CustomerWohnheimRelDC_Customer2WohnheimMapper.MapToNewDCs(pEntity.Customer2WohnheimList);
|
||||
pDataContract.Wohneinheiten = MapperFactory.WohneinheitDC_Wohneinheit.MapToNewDCs(pEntity.Wohneinheiten, pDataContract);
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
MapperFactory.EmployeeWohnheimRelDC_Employee2WohnheimMapper.MergeWithEntitys(pDataContract.RelatedEmployees, pEntity.Employee2WohnheimList);
|
||||
MapperFactory.CustomerWohnheimRelDC_Customer2WohnheimMapper.MergeWithEntitys(pDataContract.RelatedCustomers, pEntity.Customer2WohnheimList);
|
||||
MapperFactory.WohneinheitDC_Wohneinheit.MergeWithEntitys(pDataContract.Wohneinheiten, pEntity.Wohneinheiten);
|
||||
MapperFactory.WohneinheitDC_Wohneinheit.MergeWithEntitys(pDataContract.Wohneinheiten, pEntity.Wohneinheiten, pEntity);
|
||||
|
||||
return pEntity;
|
||||
}
|
||||
|
||||
@@ -2666,7 +2666,6 @@ namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Wohnheim lWohnheim = MapperFactory.WohnheimDC_Wohnheim.MapToNewEntity(pWohnheimDC);
|
||||
DAOFactory.GenericDAO.Insert(lWohnheim);
|
||||
return lWohnheim.Oid.Value;
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace BS.Shared.DataContracts
|
||||
{
|
||||
public class WohneinheitDC : DataContract
|
||||
{
|
||||
[DataMember] public long WohnheimOid { get; set; }
|
||||
[DataMember] public string Wohnname { get; set; }
|
||||
[DataMember] public string Zimmername { get; set; }
|
||||
[DataMember] public decimal Miete { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user