49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using ldap_cesi.Context;
|
|
using ldap_cesi.Entities;
|
|
using ldap_cesi.Repository.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ldap_cesi.Repository;
|
|
|
|
public class SalarieRepository : RepositoryBase<Salarie>, IRepositorySalarie
|
|
{
|
|
public SalarieRepository(PgContext context) : base(context)
|
|
{
|
|
|
|
}
|
|
|
|
public async Task<Salarie> GetSalarieWithRelationsAsync(int id)
|
|
{
|
|
return await _context.Salaries
|
|
.Include(s => s.IdServiceNavigation)
|
|
.Include(s => s.IdSiteNavigation)
|
|
.FirstOrDefaultAsync(s => s.Id == id);
|
|
}
|
|
|
|
public async Task<List<Salarie>> SearchByNameAsync(string inputRecherche)
|
|
{
|
|
return await _context.Salaries
|
|
.Where(s => s.Nom.Contains(inputRecherche) || s.Prenom.Contains(inputRecherche))
|
|
.Include(s => s.IdServiceNavigation)
|
|
.Include(s => s.IdSiteNavigation)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<List<Salarie>> GetSalariesBySiteAsync(int siteId)
|
|
{
|
|
return await _context.Salaries
|
|
.Where(s => s.IdSite == siteId)
|
|
.Include(s => s.IdServiceNavigation)
|
|
.Include(s => s.IdSiteNavigation)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<List<Salarie>> GetSalariesByServiceAsync(int serviceId)
|
|
{
|
|
return await _context.Salaries
|
|
.Where(s => s.IdService == serviceId)
|
|
.Include(s => s.IdServiceNavigation)
|
|
.Include(s => s.IdSiteNavigation)
|
|
.ToListAsync();
|
|
}
|
|
} |