using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Windows.Media; using BeWo.ServiceProxy; using BS.Shared; using BS.Shared.DataContracts.Compact; namespace BeWo.View.Search { public class CustomerSearchView : GenericSearchView { public List Customers { get { return _ObjectList; } set { base.UpdateObjectList(value); } } public CustomerSearchView() { if (!DesignerProperties.GetIsInDesignMode(this)) { this.ThemeColor = this.FindResource("CustomerContentBrush") as Brush; } } public bool FetchReferenceNumbers { get; set; } protected override void GetAll(Action> pCallBack) { // if (SearchMode == SearchMode.CostBearer) // ServiceFacade.DoCustomerServiceAsync(s => s.GetAllCostBearerCompact(), pCallBack); // else // base.GetAll(pCallBack); long? oid = null; if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View)) { oid = BeWoApp.LoggedOnUser.Employee.EmployeeOid; } ServiceFacade.DoCustomerServiceAsync( s => s.GetAllActiveCustomersCompact(this.FetchReferenceNumbers, oid), r => { List list = r; if (oid != null) { list = list.Where(c => c.IsRelatedToEmployee).ToList(); } list.Sort((x, y) => (x.LastName + ", " + x.FirstName).CompareTo(y.LastName + ", " + y.FirstName)); // (Comparison)new CustomerSorter().GetComparison("LastName", BeWo.Core.AbstractSorter.SortDirection.Ascending)); pCallBack(list); }); } } }