//-----------------------------------------------------------------------
// <copyright file=" im_employee_clinic.cs">
// * FileName: im_employee_clinic.cs
// </copyright>
//-----------------------------------------------------------------------
using Performance.EntityModels;
using System.Collections.Generic;
using System.Linq;

namespace Performance.Repository
{
    /// <summary>
    /// im_employee_clinic Repository
    /// </summary>
    public partial class PerforImemployeeclinicRepository : PerforRepository<im_employee_clinic>
    {
        public List<im_employee_clinic> GetEmployees(int allotId)
        {
            return context.Set<im_employee_clinic>()
                 .Where(w => w.AllotID == allotId)
                 .ToList()
                 .GroupBy(w => new { w.PersonnelNumber, w.UnitType, w.AccountingUnit })
                 .Select(w => w.OrderByDescending(p => p.ID).First())
                 .ToList()
                 ?? new List<im_employee_clinic>();
        }
    }
}
