using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Media;
using BeWo.ServiceProxy;

using BS.Shared;
using BS.Shared.DataContracts.Compact;

namespace BeWo.View.Search
{
    public class PersonSearchView : GenericSearchView<CompactPersonDC>
    {
        public PersonSearchView()
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                this.ThemeColor = this.FindResource("PersonContentBrush") as Brush;
            }
        }

        protected override void GetAll(Action<List<CompactPersonDC>> pCallBack)
        {
            ServiceFacade.DoCustomerServiceAsync(
            s => s.GetAllActivePersonsByTypeCompact(PersonType.Others),
            r =>
            {
                r.Sort((x, y) => { return (x.LastName + ", " + x.FirstName).CompareTo(y.LastName + ", " + y.FirstName); });

                pCallBack(r);
            });
        }
    }
}