using System.Collections.Generic; using System.ComponentModel; using System.Linq; using BeWo.ServiceProxy; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.Extensions; using DevExpress.Xpf.Layout.Core; namespace BeWo.ViewModel.ListViewModel { public class InvoiceBaseListVM : AbstractDCListMapperVM { #region Constants and Fields public static string PropertyName_DateTimeSpanFilter = "DateTimeSpanFilter"; public static string PropertyName_FilterResultAmountSum = "FilterResultAmountSum"; private DateTimeSpan _DateTimeSpanFilter; private BindingList _FilteredInvoices; #endregion #region Constructors and Destructors public InvoiceBaseListVM(List pDCs) : base(pDCs) { this.VMList.ListChanged += (s, e) => this.FirePropertyChanged(PropertyName_FilterResultAmountSum); } #endregion #region Properties public DateTimeSpan DateTimeSpanFilter { get { return this._DateTimeSpanFilter; } set { if (this.AreDifferent(this._DateTimeSpanFilter, value)) { this._DateTimeSpanFilter = value; this.FirePropertyChanged(PropertyName_DateTimeSpanFilter); } } } public decimal? FilterResultAmountSum { get { return this.VMList.Sum(e => e.TotalAmount); } } #endregion internal void UpdateList(IList dcList) { this.VMList.Clear(); this.VMList.AddRange(dcList.Select(CreateVM)); this.FirePropertyChanged(PropertyName_FilterResultAmountSum); } } }