38 lines
945 B
C#
38 lines
945 B
C#
using foundation_system.Data;
|
|
using foundation_system.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace foundation_system.Services;
|
|
|
|
public class AntecedentesService : IAntecedentesService
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
public AntecedentesService(ApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<List<AntecedenteNino>> GetHistorialByNinoIdAsync(long ninoId)
|
|
{
|
|
return await _context.AntecedentesNino
|
|
.Where(a => a.NinoId == ninoId && a.Activo)
|
|
.OrderByDescending(a => a.FechaIncidente)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<bool> AddAntecedenteAsync(AntecedenteNino antecedente)
|
|
{
|
|
try
|
|
{
|
|
_context.AntecedentesNino.Add(antecedente);
|
|
await _context.SaveChangesAsync();
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|