Files
BeWoPlaner/BeWo/View/Detail/InvoiceNumberView.xaml.cs

66 lines
1.8 KiB
C#
Raw Normal View History

2020-08-20 18:35:33 +02:00
using System.Collections.Generic;
using System.Linq;
using BeWo.ServiceProxy;
2016-06-27 01:45:38 +02:00
using BeWo.ViewModel;
2020-08-20 18:35:33 +02:00
using BS.Shared.DataContracts;
2016-06-27 01:45:38 +02:00
using BS.Shared.Extensions;
namespace BeWo.View.Detail
{
public partial class InvoiceNumberView : BeWoView
{
2020-08-20 18:35:33 +02:00
private IList<InvoiceNumberVM> _Viewmodel;
2016-06-27 01:45:38 +02:00
2020-08-20 18:35:33 +02:00
public InvoiceNumberView(IList<InvoiceNumberVM> viewModel)
2016-06-27 01:45:38 +02:00
{
this.InitializeComponent();
this.ViewModel = viewModel;
}
public override bool IsDirty
{
get
{
2020-08-20 18:35:33 +02:00
return this.ViewModel != null ? this.ViewModel.Any(v => v.IsDirty) : false;
2016-06-27 01:45:38 +02:00
}
}
2020-08-20 18:35:33 +02:00
private IList<InvoiceNumberVM> ViewModel
2016-06-27 01:45:38 +02:00
{
get
{
return this._Viewmodel;
}
set
{
this.DataContext = value;
this._Viewmodel = value;
}
}
protected override void Save()
{
2020-08-20 18:35:33 +02:00
var dcList = new List<InvoiceNumberDC>();
foreach (var vm in ViewModel)
{
dcList.Add(vm.CommitToDataContract());
}
ServiceFacade.DoAccountingServiceAsync(s => s.UpdateInvoiceNumberList(dcList), this.ReloadViewModel);
2016-06-27 01:45:38 +02:00
}
private void ReloadViewModel()
{
2020-08-20 18:35:33 +02:00
ServiceFacade.DoAccountingServiceAsync(s => s.LoadInvoiceNumberList(), r => this.Dispatch(delegate
{
var vmList = new List<InvoiceNumberVM>();
foreach (var dc in r)
{
vmList.Add(new InvoiceNumberVM(dc));
}
this.ViewModel = vmList;
}));
2016-06-27 01:45:38 +02:00
}
}
}