| | | 1 | | using FAU.Entidades; |
| | | 2 | | using Microsoft.EntityFrameworkCore; |
| | | 3 | | |
| | | 4 | | namespace FAU.DataAccess.Repositories; |
| | | 5 | | |
| | | 6 | | public class ReporteControlRepository : IReporteControlRepository |
| | | 7 | | { |
| | | 8 | | private readonly ApplicationDbContext _context; |
| | | 9 | | |
| | 0 | 10 | | public ReporteControlRepository(ApplicationDbContext context) |
| | | 11 | | { |
| | 0 | 12 | | _context = context; |
| | 0 | 13 | | } |
| | | 14 | | |
| | | 15 | | public async Task<List<RelacionLaboral>> ObtenerRelacionesActivasAsync() |
| | | 16 | | { |
| | 0 | 17 | | return await _context.RelacionesLaborales |
| | 0 | 18 | | .AsNoTracking() |
| | 0 | 19 | | .Include(r => r.Persona) |
| | 0 | 20 | | .Include(r => r.Grado) |
| | 0 | 21 | | .Include(r => r.Escalafon) |
| | 0 | 22 | | .Include(r => r.Situacion) |
| | 0 | 23 | | .Include(r => r.Programa) |
| | 0 | 24 | | .Include(r => r.Regimen) |
| | 0 | 25 | | .Where(r => r.Estado == EstadoRelacion.Activo) |
| | 0 | 26 | | .ToListAsync(); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | public async Task<List<LiquidacionItem>> ObtenerItemsLiquidacionAsync(long periodoId) |
| | | 30 | | { |
| | 0 | 31 | | var version = await _context.LiquidacionItems |
| | 0 | 32 | | .AsNoTracking() |
| | 0 | 33 | | .Where(i => i.PeriodoId == periodoId) |
| | 0 | 34 | | .MaxAsync(i => (int?)i.Version) ?? 0; |
| | | 35 | | |
| | 0 | 36 | | if (version == 0) |
| | 0 | 37 | | return new List<LiquidacionItem>(); |
| | | 38 | | |
| | 0 | 39 | | return await _context.LiquidacionItems |
| | 0 | 40 | | .AsNoTracking() |
| | 0 | 41 | | .Where(i => i.PeriodoId == periodoId && i.Version == version) |
| | 0 | 42 | | .ToListAsync(); |
| | 0 | 43 | | } |
| | | 44 | | |
| | | 45 | | } |