@page "/Rechazados" @rendermode InteractiveServer @attribute [Authorize] @using GestionaDenunciasAN.Models @using System.Globalization @attribute [StreamRendering] @inject GestionaDenunciasAN.Models.UserState userState @inject NavigationManager Navigation @inject IDenunciaStore DenunciaStore Denuncias Rechazadas

Denuncias Rechazadas

@if (!hasLoaded) {
Cargando datos...
} else if (denunciasRechazadas == null || !denunciasRechazadas.Any()) {

No hay denuncias rechazadas.

} else {
@foreach (var denuncia in denunciasRechazadas.Where(d => string.IsNullOrWhiteSpace(busqueda) || d.Id_Denuncia.ToString().Contains(busqueda) || (!string.IsNullOrEmpty(d.NombreDenuncia) && d.NombreDenuncia.Contains(busqueda, StringComparison.OrdinalIgnoreCase)) || (!string.IsNullOrEmpty(d.Estado) && d.Estado.Contains(busqueda, StringComparison.OrdinalIgnoreCase)) )) { var collapseId = $"collapse{denuncia.Id_Denuncia}";
Datos Generales
@if (denuncia.Id_RegistroDenuncia != 0) {
ID Registro Denuncia
@denuncia.Id_RegistroDenuncia
} @if (denuncia.Id_Denuncia != 0) {
ID Denuncia
@denuncia.Id_Denuncia
} @if (denuncia.Fecha != DateTime.MinValue) {
Fecha
@denuncia.Fecha.ToString("dd/MM/yyyy HH:mm")
} @if (!string.IsNullOrWhiteSpace(denuncia.ExpedienteGestionaMostrable)) {
Nº expediente Gestiona
@denuncia.ExpedienteGestionaMostrable
} @if (denuncia.Id_Persona_Gestiona != 0) {
ID Persona Gestión
@denuncia.Id_Persona_Gestiona
} @if (!string.IsNullOrWhiteSpace(denuncia.Etiqueta)) {
Etiqueta
@denuncia.Etiqueta
}
@if (!string.IsNullOrWhiteSpace(denuncia.Nombre) || !string.IsNullOrWhiteSpace(denuncia.Apellidos) || !string.IsNullOrWhiteSpace(denuncia.Sexo) || !string.IsNullOrWhiteSpace(denuncia.Dni)) {
Datos del Denunciante
@if (!string.IsNullOrWhiteSpace(denuncia.Nombre)) {
Nombre
@denuncia.Nombre
} @if (!string.IsNullOrWhiteSpace(denuncia.Apellidos)) {
Apellidos
@denuncia.Apellidos
} @if (!string.IsNullOrWhiteSpace(denuncia.Sexo)) {
Sexo
@denuncia.Sexo
} @if (!string.IsNullOrWhiteSpace(denuncia.Dni)) {
DNI
@denuncia.Dni
}
}
Detalles de la Denuncia
Asunto
@denuncia.Asunto
A Quien Denuncia
@denuncia.A_Quien_Denuncia
Descripción Denuncia
@denuncia.Descripcion_Denuncia
Denunciado Ante Inst
@denuncia.Denunciado_Ante_Inst
@if (!string.IsNullOrWhiteSpace(denuncia.Modalidad_Informacion)) {
Modalidad Información
@denuncia.Modalidad_Informacion
}
Lugar Hechos
@denuncia.Lugar_Hechos
@if (denuncia.Fecha_Hechos != DateTime.MinValue) {
Fecha Hechos
@denuncia.Fecha_Hechos.ToString("dd/MM/yyyy")
}
Datos de Notificación
@if (!string.IsNullOrWhiteSpace(denuncia.Notificacion_Preferencia)) {
Notificación Preferencia
@denuncia.Notificacion_Preferencia
} @if (!string.IsNullOrWhiteSpace(denuncia.Notificacion_Electronica)) {
Notificación Electrónica
@denuncia.Notificacion_Electronica
} @if (!string.IsNullOrWhiteSpace(denuncia.Correo_Electronico)) {
Correo Electrónico
@denuncia.Correo_Electronico
} @if (!string.IsNullOrWhiteSpace(denuncia.Notificacion_Sms)) {
Notificación SMS
@denuncia.Notificacion_Sms
}
Otros
@if (denuncia.Condiciones) {
Condiciones
} @if (!string.IsNullOrWhiteSpace(denuncia.Comments)) {
Comentarios
@denuncia.Comments
}
@if (ficherosAdjuntos.ContainsKey(denuncia.Id_Denuncia) && ficherosAdjuntos[denuncia.Id_Denuncia].Any()) {
Ficheros Adjuntos
@foreach (var fichero in ficherosAdjuntos[denuncia.Id_Denuncia]) { }
Nombre Tamaño (bytes) Ver
@fichero.NombreFichero @fichero.Fichero.Length Ver
}
}
} @code { private List denunciasRechazadas = new(); private Dictionary> ficherosAdjuntos = new(); // Variable para la búsqueda private string busqueda = ""; private bool hasLoaded = false; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await CargarRechazadasAsync(); await CargarFicherosAdjuntosAsync(); hasLoaded = true; StateHasChanged(); } } private async Task CargarRechazadasAsync() { var todas = await CargarDenunciasJsonAsync(); // Ahora filtramos por la bandera EnRechazada denunciasRechazadas = todas .Where(d => d.EnRechazada) .ToList(); } private async Task> CargarDenunciasJsonAsync() { return await DenunciaStore.GetAllDenunciasAsync(); } private async Task> CargarFicherosJsonAsync() { return await DenunciaStore.GetAllFicherosAsync(); } private async Task CargarFicherosAdjuntosAsync() { var listaFicheros = await CargarFicherosJsonAsync(); ficherosAdjuntos = listaFicheros.GroupBy(f => f.Id_Denuncia) .ToDictionary(g => g.Key, g => g.ToList()); } private string GetContentType(string fileName) { var ext = Path.GetExtension(fileName).ToLowerInvariant(); return ext switch { ".jpg" or ".jpeg" => "image/jpeg", ".png" => "image/png", ".gif" => "image/gif", ".pdf" => "application/pdf", ".txt" => "text/plain", _ => "application/octet-stream", }; } }