518 lines
17 KiB
C#
518 lines
17 KiB
C#
using BeWo.ViewModel.ListViewModel;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class WohneinheitVM : AbstractDCMapperVM<WohneinheitDC>
|
|
{
|
|
private long? _Oid;
|
|
private long? _Version;
|
|
private string _Notice;
|
|
|
|
private string _Wohnname;
|
|
private string _Zimmername;
|
|
private decimal? _Miete;
|
|
private decimal? _Heizung;
|
|
private decimal? _Strom;
|
|
private decimal? _Betriebskosten;
|
|
private decimal? _SonstigeKosten;
|
|
private decimal? _Kaution;
|
|
private decimal? _QM;
|
|
private int? _Baujahr;
|
|
private string _Mobilierung;
|
|
private string _Zusatznotiz;
|
|
private string _Stock;
|
|
private ImageListVM _ImageListVM;
|
|
private string _Details1;
|
|
private string _Details2;
|
|
private string _Details3;
|
|
private string _Details4;
|
|
private string _Details5;
|
|
private string _Details6;
|
|
private string _Details7;
|
|
private string _Details8;
|
|
private string _Details9;
|
|
private string _Details10;
|
|
|
|
public WohneinheitVM() : this(new WohneinheitDC())
|
|
{
|
|
Wohnname = "Designer Wohnung";
|
|
}
|
|
|
|
public WohneinheitVM(WohneinheitDC dc) : base(dc, dc.Oid == null)
|
|
{
|
|
|
|
}
|
|
|
|
public long? Oid => _Oid;
|
|
|
|
public string Wohnname
|
|
{
|
|
get { return _Wohnname; }
|
|
set
|
|
{
|
|
if (!AreDifferent(Wohnname, value))
|
|
return;
|
|
|
|
_Wohnname = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Wohnname, value), nameof(Wohnname));
|
|
FirePropertyChanged(nameof(Wohnname));
|
|
FirePropertyChanged(nameof(Caption));
|
|
FirePropertyChanged(nameof(Group));
|
|
FirePropertyChanged(nameof(Displayname));
|
|
FirePropertyChanged(nameof(Displayname2));
|
|
}
|
|
}
|
|
public string Zimmername
|
|
{
|
|
get { return _Zimmername; }
|
|
set
|
|
{
|
|
if (!AreDifferent(Zimmername, value))
|
|
return;
|
|
|
|
_Zimmername = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Zimmername, value), nameof(Zimmername));
|
|
FirePropertyChanged(nameof(Zimmername));
|
|
FirePropertyChanged(nameof(Caption));
|
|
FirePropertyChanged(nameof(Group));
|
|
FirePropertyChanged(nameof(Displayname));
|
|
FirePropertyChanged(nameof(Displayname2));
|
|
}
|
|
}
|
|
public string Name => ToString();
|
|
public decimal? Miete
|
|
{
|
|
get { return _Miete; }
|
|
set
|
|
{
|
|
if (!AreDifferent(Miete, value))
|
|
return;
|
|
_Miete = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Miete, value), nameof(Miete));
|
|
FirePropertyChanged(nameof(Miete));
|
|
FirePropertyChanged(nameof(Brutto));
|
|
}
|
|
}
|
|
public decimal? Heizung
|
|
{
|
|
get { return _Heizung; }
|
|
set
|
|
{
|
|
if (AreDifferent(Heizung, value))
|
|
{
|
|
_Heizung = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Heizung, value), nameof(Heizung));
|
|
FirePropertyChanged(nameof(Heizung));
|
|
FirePropertyChanged(nameof(Brutto));
|
|
}
|
|
}
|
|
}
|
|
public decimal? Strom
|
|
{
|
|
get { return _Strom; }
|
|
set
|
|
{
|
|
if (AreDifferent(Strom, value))
|
|
{
|
|
_Strom = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Strom, value), nameof(Strom));
|
|
FirePropertyChanged(nameof(Strom));
|
|
FirePropertyChanged(nameof(Brutto));
|
|
}
|
|
}
|
|
}
|
|
public decimal? Betriebskosten
|
|
{
|
|
get { return _Betriebskosten; }
|
|
set
|
|
{
|
|
if (AreDifferent(Betriebskosten, value))
|
|
{
|
|
_Betriebskosten = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Betriebskosten, value), nameof(Betriebskosten));
|
|
FirePropertyChanged(nameof(Betriebskosten));
|
|
FirePropertyChanged(nameof(Brutto));
|
|
}
|
|
}
|
|
}
|
|
public decimal? SonstigeKosten
|
|
{
|
|
get { return _SonstigeKosten; }
|
|
set
|
|
{
|
|
if (AreDifferent(SonstigeKosten, value))
|
|
{
|
|
_SonstigeKosten = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.SonstigeKosten, value), nameof(SonstigeKosten));
|
|
FirePropertyChanged(nameof(SonstigeKosten));
|
|
FirePropertyChanged(nameof(Brutto));
|
|
}
|
|
}
|
|
}
|
|
public decimal? Kaution
|
|
{
|
|
get { return _Kaution; }
|
|
set
|
|
{
|
|
if (AreDifferent(Kaution, value))
|
|
{
|
|
_Kaution = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Kaution, value), nameof(Kaution));
|
|
FirePropertyChanged(nameof(Kaution));
|
|
}
|
|
}
|
|
}
|
|
public decimal? Brutto
|
|
{
|
|
get
|
|
{
|
|
if (!Miete.HasValue
|
|
&& !Heizung.HasValue
|
|
&& !Strom.HasValue
|
|
&& !Betriebskosten.HasValue
|
|
&& !SonstigeKosten.HasValue)
|
|
return null;
|
|
|
|
return (Miete ?? 0)
|
|
+ (Heizung ?? 0)
|
|
+ (Strom ?? 0)
|
|
+ (Betriebskosten ?? 0)
|
|
+ (SonstigeKosten ?? 0);
|
|
}
|
|
}
|
|
public decimal? QM
|
|
{
|
|
get { return _QM; }
|
|
set
|
|
{
|
|
if (!AreDifferent(QM, value))
|
|
return;
|
|
|
|
if (value == 0)
|
|
value = null;
|
|
|
|
_QM = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.QM, value), nameof(QM));
|
|
FirePropertyChanged(nameof(QM));
|
|
FirePropertyChanged(nameof(FlacheString));
|
|
}
|
|
}
|
|
public string FlacheString => QM?.ToString("########0.00 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 string Details1
|
|
{
|
|
get { return _Details1; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details1, value))
|
|
{
|
|
_Details1 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details1, value), nameof(Details1));
|
|
FirePropertyChanged(nameof(Details1));
|
|
}
|
|
}
|
|
}
|
|
public string Details2
|
|
{
|
|
get { return _Details2; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details2, value))
|
|
{
|
|
_Details2 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details2, value), nameof(Details2));
|
|
FirePropertyChanged(nameof(Details2));
|
|
}
|
|
}
|
|
}
|
|
public string Details3
|
|
{
|
|
get { return _Details3; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details3, value))
|
|
{
|
|
_Details3 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details3, value), nameof(Details3));
|
|
FirePropertyChanged(nameof(Details3));
|
|
}
|
|
}
|
|
}
|
|
public string Details4
|
|
{
|
|
get { return _Details4; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details4, value))
|
|
{
|
|
_Details4 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details4, value), nameof(Details4));
|
|
FirePropertyChanged(nameof(Details4));
|
|
}
|
|
}
|
|
}
|
|
public string Details5
|
|
{
|
|
get { return _Details5; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details5, value))
|
|
{
|
|
_Details5 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details5, value), nameof(Details5));
|
|
FirePropertyChanged(nameof(Details5));
|
|
}
|
|
}
|
|
}
|
|
public string Details6
|
|
{
|
|
get { return _Details6; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details6, value))
|
|
{
|
|
_Details6 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details6, value), nameof(Details6));
|
|
FirePropertyChanged(nameof(Details6));
|
|
}
|
|
}
|
|
}
|
|
public string Details7
|
|
{
|
|
get { return _Details7; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details7, value))
|
|
{
|
|
_Details7 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details7, value), nameof(Details7));
|
|
FirePropertyChanged(nameof(Details7));
|
|
}
|
|
}
|
|
}
|
|
public string Details8
|
|
{
|
|
get { return _Details8; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details8, value))
|
|
{
|
|
_Details8 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details8, value), nameof(Details8));
|
|
FirePropertyChanged(nameof(Details8));
|
|
}
|
|
}
|
|
}
|
|
public string Details9
|
|
{
|
|
get { return _Details9; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details9, value))
|
|
{
|
|
_Details9 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details9, value), nameof(Details9));
|
|
FirePropertyChanged(nameof(Details9));
|
|
}
|
|
}
|
|
}
|
|
public string Details10
|
|
{
|
|
get { return _Details10; }
|
|
set
|
|
{
|
|
if (AreDifferent(Details10, value))
|
|
{
|
|
_Details10 = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Details10, value), nameof(Details10));
|
|
FirePropertyChanged(nameof(Details10));
|
|
}
|
|
}
|
|
}
|
|
public ImageListVM ImageListVM
|
|
{
|
|
get { return _ImageListVM; }
|
|
|
|
set
|
|
{
|
|
if (_ImageListVM == value)
|
|
return;
|
|
|
|
_ImageListVM = value;
|
|
FirePropertyChanged(nameof(ImageListVM));
|
|
}
|
|
}
|
|
|
|
public override bool IsDirty => base.IsDirty || ImageListVM.IsDirty;
|
|
|
|
public bool IsEinzelwohnung => string.IsNullOrEmpty(Zimmername);
|
|
|
|
public string Caption => IsEinzelwohnung ? Wohnname : Zimmername ;
|
|
public string Group => IsEinzelwohnung ? null : Wohnname;
|
|
|
|
public string Displayname => IsEinzelwohnung ? Wohnname : Wohnname + "\n- " + Zimmername;
|
|
public string Displayname2 => IsEinzelwohnung ? Wohnname : Wohnname + " - " + Zimmername;
|
|
|
|
public bool HasEmptyZimmername()
|
|
{
|
|
return string.IsNullOrEmpty(Zimmername);
|
|
}
|
|
|
|
public static int Compare(WohneinheitVM vm1, WohneinheitVM vm2)
|
|
{
|
|
if (vm1 is null)
|
|
return 1;
|
|
|
|
if (vm2 is null)
|
|
return -1;
|
|
|
|
var compare1 = string.Compare(vm1.Wohnname, vm2.Wohnname);
|
|
|
|
if (compare1 != 0)
|
|
return compare1;
|
|
|
|
var compare2 = string.Compare(vm1.Zimmername, vm2.Zimmername);
|
|
|
|
return compare2;
|
|
}
|
|
|
|
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;
|
|
_Kaution = pDataContract.Kaution;
|
|
_QM = pDataContract.QM;
|
|
_Baujahr = pDataContract.Baujahr;
|
|
_Mobilierung = pDataContract.Mobilierung;
|
|
_Zusatznotiz = pDataContract.Zusatznotiz;
|
|
_Stock = pDataContract.Stock;
|
|
_Details1 = pDataContract.Details1;
|
|
_Details2 = pDataContract.Details2;
|
|
_Details3 = pDataContract.Details3;
|
|
_Details4 = pDataContract.Details4;
|
|
_Details5 = pDataContract.Details5;
|
|
_Details6 = pDataContract.Details6;
|
|
_Details7 = pDataContract.Details7;
|
|
_Details8 = pDataContract.Details8;
|
|
_Details9 = pDataContract.Details9;
|
|
_Details10 = pDataContract.Details10;
|
|
|
|
|
|
_ImageListVM = new ImageListVM(pDataContract.Grundrisse ?? (pDataContract.Grundrisse = new List<ImageDC>()));
|
|
}
|
|
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.Kaution = _Kaution;
|
|
bDataContract.QM = _QM;
|
|
bDataContract.Baujahr = _Baujahr;
|
|
bDataContract.Mobilierung = _Mobilierung;
|
|
bDataContract.Zusatznotiz = _Zusatznotiz;
|
|
bDataContract.Stock = _Stock;
|
|
bDataContract.Details1 = _Details1;
|
|
bDataContract.Details2 = _Details2;
|
|
bDataContract.Details3 = _Details3;
|
|
bDataContract.Details4 = _Details4;
|
|
bDataContract.Details5 = _Details5;
|
|
bDataContract.Details6 = _Details6;
|
|
bDataContract.Details7 = _Details7;
|
|
bDataContract.Details8 = _Details8;
|
|
bDataContract.Details9 = _Details9;
|
|
bDataContract.Details10 = _Details10;
|
|
|
|
bDataContract.Belegungen = null;
|
|
|
|
bDataContract.Grundrisse = ImageListVM.CopyToDCList(doCommit);
|
|
|
|
return bDataContract;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
if (HasEmptyZimmername())
|
|
return Wohnname;
|
|
return $"{Wohnname}, {Zimmername}";
|
|
}
|
|
}
|
|
}
|