88 lines
4.2 KiB
Plaintext
88 lines
4.2 KiB
Plaintext
@model List<vita_asistente.Data.Models.Paciente>
|
|
|
|
@{
|
|
ViewData["Title"] = "Pacientes";
|
|
Layout = "_Layout";
|
|
}
|
|
|
|
<div class="container mt-4">
|
|
<h2>Lista de Pacientes</h2>
|
|
|
|
@if (User.IsInRole("Admin"))
|
|
{
|
|
<a asp-action="Create" class="btn btn-success mb-3">Nuevo Paciente</a>
|
|
}
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form asp-action="Index" method="get" class="row g-3 mb-4">
|
|
<div class="col-md-5">
|
|
<label for="nombreBusqueda" class="form-label">Nombre o Documento</label>
|
|
<input type="text" class="form-control" id="nombreBusqueda" name="nombreBusqueda"
|
|
placeholder="Buscar por nombre o documento..." value="@ViewBag.NombreBusqueda">
|
|
</div>
|
|
<div class="col-md-2 d-flex align-items-end">
|
|
<button type="submit" class="btn btn-primary me-3">Buscar</button>
|
|
@if (!string.IsNullOrEmpty(ViewBag.NombreBusqueda))
|
|
{
|
|
<a asp-action="Index" class="btn btn-outline-secondary">Limpiar</a>
|
|
}
|
|
</div>
|
|
</form>
|
|
|
|
<table class="table table-striped">
|
|
<thead class="table-dark">
|
|
<tr>
|
|
<th>Documento</th>
|
|
<th>Nombre Completo</th>
|
|
<th>Email</th>
|
|
<th>Fecha Registro</th>
|
|
<th>Estado</th>
|
|
<th>Acciones</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var paciente in Model)
|
|
{
|
|
<tr>
|
|
<td>@Html.DisplayFor(modelItem => paciente.Documento)</td>
|
|
<td>@Html.DisplayFor(modelItem => paciente.Nombre) @Html.DisplayFor(modelItem => paciente.Apellido)</td>
|
|
<td>@Html.DisplayFor(modelItem => paciente.Email)</td>
|
|
<td>@Html.DisplayFor(modelItem => paciente.FechaRegistro.ToShortDateString())</td>
|
|
<td>
|
|
@if (paciente.IsActive)
|
|
{
|
|
<span class="badge bg-success">Activo</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="badge bg-danger">Inactivo</span>
|
|
}
|
|
</td>
|
|
<td>
|
|
@if (User.IsInRole("Admin") || (User.Identity != null && User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier")?.Value == paciente.Id))
|
|
{
|
|
<a asp-action="Details" asp-route-id="@paciente.Id" class="btn btn-sm btn-info">Ver</a>
|
|
@if (User.IsInRole("Admin"))
|
|
{
|
|
<a asp-action="Edit" asp-route-id="@paciente.Id" class="btn btn-sm btn-warning ms-1">Editar</a>
|
|
@if (!paciente.IsActive)
|
|
{
|
|
<form asp-action="Activate" asp-route-id="@paciente.Id" class="d-inline">
|
|
<button type="submit" class="btn btn-sm btn-success ms-1" onclick="return confirm('¿Activar este paciente?');">Activar</button>
|
|
</form>
|
|
}
|
|
else
|
|
{
|
|
<a asp-action="Delete" asp-route-id="@paciente.Id" class="btn btn-sm btn-danger ms-1">Desactivar</a>
|
|
}
|
|
}
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div> |