Files
BeWoPlaner/BeWo/View/Search/TextModuleSearchView.cs
2018-01-16 17:11:02 +01:00

57 lines
1.8 KiB
C#

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;
using BS.Shared.Extensions;
namespace BeWo.View.Search
{
public class TextModuleSearchView : GenericSearchView<TextModuleDC>
{
private long _ServiceCategoryOid;
public long ServiceCategoryOid
{
get => _ServiceCategoryOid;
set
{
_ServiceCategoryOid = value;
ServiceFacade.DoOperationsServiceAsync(s => s.GetTextModulesByServiceCategory(ServiceCategoryOid), r =>
{
r = r.OrderBy(tb => tb.Position).ThenBy(tb => tb.Name).ToList();
this.Dispatch(() => UpdateObjectList(r));
});
}
}
public TextModuleSearchView()
{
if (!DesignerProperties.GetIsInDesignMode(this))
{
ThemeColor = FindResource("TextModuleBrush") as Brush;
}
}
protected override void GetAll(Action<List<TextModuleDC>> pCallBack)
{
ServiceFacade.DoOperationsServiceAsync(s => s.GetTextModulesByServiceCategory(ServiceCategoryOid), r =>
{
r = r.OrderBy(tb => tb.ServiceCategory == null).ThenBy(tb => tb.Position).ThenBy(tb => tb.Name).ToList();
r = !BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleAnsehen) ?
r.Where(w => w.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)).ToList() :
r.Where(w => !(w.IsOnlyForEmployee && !w.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))).ToList();
pCallBack(r);
});
}
}
}