größere Strukturänderung
This commit is contained in:
@@ -465,7 +465,7 @@ namespace BeWo.View.Detail
|
||||
|
||||
private void Button_NewBuchung_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
popup_newBuchung.ViewModel =
|
||||
popup_newBuchung.ViewModel = new WohneinheitBelegungVM();
|
||||
|
||||
popup_newBuchung.IsOpen = true;
|
||||
|
||||
|
||||
@@ -51,13 +51,33 @@ namespace BeWo.ViewModel
|
||||
|
||||
protected virtual void FirePropertyChanged(string pPropertyName)
|
||||
{
|
||||
FirePropertyChanged(PropertyChanged, pPropertyName);
|
||||
FirePropertyChanged(PropertyChanged, this, pPropertyName);
|
||||
}
|
||||
|
||||
protected void FirePropertyChanged(PropertyChangedEventHandler handler, string pPropertyName)
|
||||
{
|
||||
FirePropertyChanged(handler, this, pPropertyName);
|
||||
}
|
||||
|
||||
protected void FirePropertyChanged(object sender, string pPropertyName)
|
||||
{
|
||||
FirePropertyChanged(PropertyChanged, sender, pPropertyName);
|
||||
}
|
||||
|
||||
protected void FirePropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
FirePropertyChanged(PropertyChanged, sender, e);
|
||||
}
|
||||
|
||||
protected void FirePropertyChanged(PropertyChangedEventHandler handler, object sender, string pPropertyName)
|
||||
{
|
||||
FirePropertyChanged(handler, sender, new PropertyChangedEventArgs(pPropertyName));
|
||||
}
|
||||
|
||||
protected void FirePropertyChanged(PropertyChangedEventHandler handler, object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
_IsDirty = true;
|
||||
handler?.Invoke(this, new PropertyChangedEventArgs(pPropertyName));
|
||||
handler?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,26 +11,21 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
public class WohneinheitBelegungListVM : AbstractDCListMapperVM<WohneinheitBelegungDC, WohneinheitBelegungVM>
|
||||
{
|
||||
private WohnheimVM _Wohnheim;
|
||||
private WohneinheitBelegungVM _CurrentVM;
|
||||
public WohneinheitVM Parent { get; set; }
|
||||
public WohneinheitBelegungVM Current { get; set; }
|
||||
|
||||
private WohneinheitVM _ParentVM;
|
||||
|
||||
public WohneinheitBelegungListVM(List<WohneinheitBelegungDC> pDCs, WohneinheitVM parentVm) : base(pDCs)
|
||||
public WohneinheitBelegungListVM(List<WohneinheitBelegungVM> vms) : base()
|
||||
{
|
||||
_ParentVM = parentVm;
|
||||
VMList = new BindingList<WohneinheitBelegungVM>(vms);
|
||||
}
|
||||
|
||||
public WohneinheitBelegungVM CurrentVM
|
||||
public WohneinheitBelegungListVM(List<WohneinheitBelegungDC> pDCs, WohneinheitVM wohneinheitVM) : base(pDCs)
|
||||
{
|
||||
get => _CurrentVM;
|
||||
set
|
||||
{
|
||||
if (!AreDifferent(_CurrentVM, value))
|
||||
return;
|
||||
Parent = wohneinheitVM;
|
||||
|
||||
_CurrentVM = value;
|
||||
FirePropertyChanged(nameof(CurrentVM));
|
||||
foreach (var beleg in VMList)
|
||||
{
|
||||
beleg.Parent = Parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,23 +33,10 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
var vm = base.AddNewVMToList();
|
||||
|
||||
CurrentVM = null;
|
||||
Parent.Belegungen.VMList.Add(vm);
|
||||
Parent.Wohnheim.WohneinheitListVM.WohneinheitBelegungListVM.VMList.Add(vm);
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
public void CloseEditVM()
|
||||
{
|
||||
EditVM = null;
|
||||
|
||||
CurrentVM = null;
|
||||
}
|
||||
|
||||
public void CloseNewVM()
|
||||
{
|
||||
NewVM = null;
|
||||
|
||||
CurrentVM = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,24 +13,56 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
private WohnheimVM _Wohnheim;
|
||||
private WohneinheitVM _CurrentVM;
|
||||
private BindingList<WohneinheitBelegungVM> _Belegungen;
|
||||
|
||||
private BindingList<string> _Wohnungsnamen;
|
||||
|
||||
private WohneinheitBelegungListVM _WohneinheitBelegungListVM;
|
||||
|
||||
public WohneinheitListVM(List<WohneinheitDC> pDCs, WohnheimVM parentVm) : base(pDCs)
|
||||
{
|
||||
_Wohnheim = parentVm;
|
||||
|
||||
var belegungen = new List<WohneinheitBelegungVM>();
|
||||
var list = new List<WohneinheitBelegungVM>();
|
||||
VMList.DoForEach(x =>
|
||||
{
|
||||
x.Wohnheim = _Wohnheim;
|
||||
|
||||
belegungen.AddRange(x.Belegungen.VMList);
|
||||
list.AddRange(x.Belegungen.VMList);
|
||||
//x.Belegungen = new BindingList<WohneinheitBelegungVM>(belegListVM.VMList.Where(beleg => beleg.Parent == x).ToList());
|
||||
});
|
||||
|
||||
_Belegungen = new BindingList<WohneinheitBelegungVM>(belegungen);
|
||||
WohneinheitBelegungListVM = new WohneinheitBelegungListVM(list);
|
||||
|
||||
_Wohnungsnamen = new BindingList<string>(GetWohnungsnamen());
|
||||
|
||||
//var belegungs_dcs = pDCs.SelectMany(x => x.Belegungen).ToList();
|
||||
//var belegung_list_vm = new WohneinheitBelegungListVM(belegungs_dcs);
|
||||
//
|
||||
//Dictionary<long, WohneinheitVM> beleg2parent = new Dictionary<long, WohneinheitVM>();
|
||||
//foreach (var einheit_vm in VMList)
|
||||
//{
|
||||
// foreach (var beleg_dc in einheit_vm.DataContract.Belegungen)
|
||||
// {
|
||||
// beleg2parent.Add(beleg_dc.Oid.Value, einheit_vm);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//foreach (var belegung_vm in belegung_list_vm.VMList)
|
||||
//{
|
||||
// belegung_vm.Parent = beleg2parent[belegung_vm.Oid.Value];
|
||||
//}
|
||||
//
|
||||
//_Belegungen = new BindingList<WohneinheitBelegungVM>(belegungen);
|
||||
}
|
||||
|
||||
public WohneinheitBelegungListVM WohneinheitBelegungListVM
|
||||
{
|
||||
get { return _WohneinheitBelegungListVM; }
|
||||
|
||||
set
|
||||
{
|
||||
_WohneinheitBelegungListVM = value;
|
||||
FirePropertyChanged(nameof(WohneinheitBelegungListVM));
|
||||
}
|
||||
}
|
||||
|
||||
public WohneinheitVM CurrentVM
|
||||
@@ -70,6 +102,8 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
return vm;
|
||||
}
|
||||
|
||||
public override bool IsDirty => base.IsDirty || WohneinheitBelegungListVM.IsDirty;
|
||||
|
||||
public void CloseEditVM()
|
||||
{
|
||||
EditVM = null;
|
||||
|
||||
@@ -869,5 +869,15 @@ namespace BeWo.ViewModel
|
||||
return folderList;
|
||||
}
|
||||
|
||||
public static WohneinheitListVM CreateWohneinheitListVMs(List<WohneinheitDC> dcs, WohnheimVM parent)
|
||||
{
|
||||
// var belegung_dcs = dcs.SelectMany(x => x.Belegungen).ToList();
|
||||
|
||||
//var belegung_list_vm = new WohneinheitBelegungListVM(belegung_dcs);
|
||||
|
||||
var einheit_list_vm = new WohneinheitListVM(dcs, parent);
|
||||
|
||||
return einheit_list_vm;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,10 @@ namespace BeWo.ViewModel
|
||||
private DateTime? _EndDate;
|
||||
private string _Kommentar;
|
||||
|
||||
public WohneinheitBelegungVM() : base(new WohneinheitBelegungDC(), true)
|
||||
{
|
||||
|
||||
}
|
||||
public WohneinheitBelegungVM(WohneinheitBelegungDC dc) : base(dc, dc.Oid == null)
|
||||
{
|
||||
|
||||
@@ -27,6 +31,25 @@ namespace BeWo.ViewModel
|
||||
|
||||
public long? Oid => _Oid;
|
||||
|
||||
public WohneinheitVM Parent
|
||||
{
|
||||
get { return _Parent; }
|
||||
set
|
||||
{
|
||||
if (!AreDifferent(Parent, value))
|
||||
return;
|
||||
|
||||
if (_Parent is object)
|
||||
_Parent.PropertyChanged -= FirePropertyChanged;
|
||||
|
||||
_Parent = value;
|
||||
|
||||
if (_Parent is object)
|
||||
_Parent.PropertyChanged += FirePropertyChanged;
|
||||
|
||||
FirePropertyChanged(nameof(Parent));
|
||||
}
|
||||
}
|
||||
public long? CustomerOid
|
||||
{
|
||||
get { return _CustomerOid; }
|
||||
@@ -39,7 +62,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(nameof(CustomerOid));
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime StartDate
|
||||
{
|
||||
get { return _StartDate; }
|
||||
@@ -53,7 +75,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(nameof(StartDate));
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? EndDate
|
||||
{
|
||||
get { return _EndDate; }
|
||||
|
||||
@@ -70,8 +70,8 @@ namespace BeWo.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.IsDirty || WohnheimEmployeeRelations.IsDirty
|
||||
|| WohnheimCustomerRelations.IsDirty
|
||||
return base.IsDirty || WohnheimEmployeeRelations.IsDirty
|
||||
|| WohnheimCustomerRelations.IsDirty
|
||||
|| WohneinheitListVM.IsDirty;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(PropertyName_WohnheimName);
|
||||
}
|
||||
}
|
||||
|
||||
public String Strasse
|
||||
{
|
||||
|
||||
@@ -123,7 +122,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(PropertyName_Street);
|
||||
}
|
||||
}
|
||||
|
||||
public String PLZ
|
||||
{
|
||||
get
|
||||
@@ -137,7 +135,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(PropertyName_PLZ);
|
||||
}
|
||||
}
|
||||
|
||||
public String Ort
|
||||
{
|
||||
get
|
||||
@@ -151,7 +148,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(PropertyName_Ort);
|
||||
}
|
||||
}
|
||||
|
||||
public String Bemerkung
|
||||
{
|
||||
|
||||
@@ -167,7 +163,6 @@ namespace BeWo.ViewModel
|
||||
FirePropertyChanged(PropertyName_Bemerkung);
|
||||
}
|
||||
}
|
||||
|
||||
public String PflichtbesetzungStart
|
||||
{
|
||||
|
||||
@@ -326,7 +321,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>()), this);
|
||||
WohneinheitListVM = VMFactory.CreateWohneinheitListVMs(pDataContract.Wohneinheiten ?? (pDataContract.Wohneinheiten = new List<WohneinheitDC>()), this);
|
||||
}
|
||||
|
||||
protected override WohnheimDC MapToDataContract(WohnheimDC pDataContract, bool doCommit)
|
||||
|
||||
Reference in New Issue
Block a user