Creada api y primer verbo buscar ficheros faltantes
This commit is contained in:
67
APIFicheros/Controllers/ObtenerFicherosController.cs
Normal file
67
APIFicheros/Controllers/ObtenerFicherosController.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using APIFicheros.DTOs;
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using static Org.BouncyCastle.Math.EC.ECCurve;
|
||||
|
||||
namespace APIFicheros.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ObtenerFicherosController : Controller
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private bdAsegasa.tscgestionasegasa bd;
|
||||
public ObtenerFicherosController(IConfiguration configuration)
|
||||
{
|
||||
|
||||
_configuration = configuration;
|
||||
|
||||
var nombreConexion = _configuration["Configuracion:NombreConexionBD"];
|
||||
|
||||
bd = tscgestionasegasa.NuevoContexto(nombreConexion, true, false, true, "ObtenerFicheros");
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("ObtenerFicherosFaltantes")]
|
||||
public ActionResult PostNombreBD([FromBody] string numeroPoliza)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
int idPoliza = bd.polizassg.First(x => x.NumeroPoliza!.Contains(numeroPoliza)).idPoliza;
|
||||
|
||||
|
||||
List<bdAsegasa.db.documentospolizassg> listadoDocumentos = new List<bdAsegasa.db.documentospolizassg>();
|
||||
List<PolizasFaltantes> listadoFicherosFaltantes = new List<PolizasFaltantes>();
|
||||
|
||||
listadoDocumentos = bd.documentospolizassg.Where(x => x.idPoliza == idPoliza && x.idFichero == null).ToList();
|
||||
|
||||
|
||||
foreach (documentospolizassg documentoFaltante in listadoDocumentos)
|
||||
{
|
||||
listadoFicherosFaltantes.Add(new PolizasFaltantes
|
||||
{
|
||||
idDocumento = documentoFaltante.idDocumento,
|
||||
descripcion = documentoFaltante.idDocumentoASolicitarNavigation!.idTipoNavigation!.Descripcion
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(listadoFicherosFaltantes);
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
return BadRequest("Ha ocurrido un error. Mensaje de error: " + ex.Message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user