Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from RFGRONA/Alpha-Fredy
Browse files Browse the repository at this point in the history
FX, views - view styles - filters ticket - pdf report
  • Loading branch information
RFGRONA authored May 18, 2024
2 parents 1f269dc + 286c8a3 commit b40ada2
Show file tree
Hide file tree
Showing 28 changed files with 252 additions and 80 deletions.
10 changes: 8 additions & 2 deletions Controllers/TicketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ public TicketController(TicketService ticketService, StateService stateService,
}

// GET: TicketController
public ActionResult Index()
public ActionResult Index(string filter)
{
var tickets = ticketService.GetAllTickets();
IEnumerable<TicketDto> tickets;
if(filter=="Pending")
tickets = ticketService.GetTicketsPending();
else if (filter == "Answer")
tickets = ticketService.GetTicketsAnswers();
else
tickets = ticketService.GetAllTickets();
return View(tickets);
}

Expand Down
64 changes: 63 additions & 1 deletion Repository/TicketRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public List<TicketDto> GetListTicket()
try
{
var states = _context.States.ToDictionary(s => s.IdState, s => s.NameState);
var ticketEntities = _context.Tickets;
var ticketEntities = _context.Tickets.OrderBy(t => t.State);
var tickets = new List<TicketDto>();
if(ticketEntities == null)
return null;
Expand All @@ -92,6 +92,68 @@ public List<TicketDto> GetListTicket()
}
}

public List<TicketDto> GetTicketsAnswer()
{
try
{
var states = _context.States.ToDictionary(s => s.IdState, s => s.NameState);
var ticketEntities = _context.Tickets.Where(t => t.State == 7);
var tickets = new List<TicketDto>();
if (ticketEntities == null)
return null;
foreach (var ticket in ticketEntities)
{
var ticketDto = new TicketDto
{
IdTicket = ticket.IdTicket,
Type = ticket.Type,
Affair = ticket.Affair,
UserId = ticket.UserId,
StateName = states.ContainsKey((int)ticket.State) ? states[(int)ticket.State] : null,
Answer = ticket.Answer
};
tickets.Add(ticketDto);
}
return tickets;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}

public List<TicketDto> GetTicketsPending()
{
try
{
var states = _context.States.ToDictionary(s => s.IdState, s => s.NameState);
var ticketEntities = _context.Tickets.Where(t => t.State == 6);
var tickets = new List<TicketDto>();
if (ticketEntities == null)
return null;
foreach (var ticket in ticketEntities)
{
var ticketDto = new TicketDto
{
IdTicket = ticket.IdTicket,
Type = ticket.Type,
Affair = ticket.Affair,
UserId = ticket.UserId,
StateName = states.ContainsKey((int)ticket.State) ? states[(int)ticket.State] : null,
Answer = ticket.Answer
};
tickets.Add(ticketDto);
}
return tickets;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}

public TicketDto Update(TicketDto ticket)
{
try
Expand Down
10 changes: 10 additions & 0 deletions Services/TicketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public IEnumerable<TicketDto> GetAllTickets()
return ticketRepo.GetListTicket() ?? new List<TicketDto>();
}

public IEnumerable<TicketDto> GetTicketsAnswers()
{
return ticketRepo.GetTicketsAnswer() ?? new List<TicketDto>();
}

public IEnumerable<TicketDto> GetTicketsPending()
{
return ticketRepo.GetTicketsPending() ?? new List<TicketDto>();
}

public TicketDto GetTicket(int id)
{
return ticketRepo.GetTicket(id);
Expand Down
2 changes: 1 addition & 1 deletion Views/Activity/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group input-container">
<label class="control-label">Tipo</label>
<input asp-for="Type" required class="form-control" />
<input asp-for="Type" maxlength="128" required class="form-control" />
<span asp-validation-for="Type" class="text-danger"></span>
</div>
<div class="form-group input-container">
Expand Down
4 changes: 2 additions & 2 deletions Views/Home/Login.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<form asp-controller="Home" asp-action="Login" method="post">
<div class="form-group">
<label asp-for="Email">Correo Electrónico</label>
<input asp-for="Email" class="form-control" type="email" required />
<input asp-for="Email" maxlength="75" class="form-control" type="email" required />
<div class="text-danger">@Html.ValidationMessage("Email")</div>
</div>
<div class="form-group">
<label asp-for="Password">Contraseña</label>
<input asp-for="Password" class="form-control" type="password" required />
<input asp-for="Password" maxlength="255" class="form-control" type="password" required />
<div class="text-danger">@Html.ValidationMessage("Password")</div>
</div>
<div class="check">
Expand Down
6 changes: 3 additions & 3 deletions Views/Home/Register.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
<form id="registerForm" asp-controller="Home" asp-action="Register" method="post">
<div class="form-group">
<label asp-for="NameUser">Nombre</label>
<input asp-for="NameUser" class="form-control" type="text" required placeholder="Jose Perez" />
<input asp-for="NameUser" class="form-control" maxlength="65" type="text" required placeholder="Jose Perez" />
</div>
<div class="form-group">
<label asp-for="Email">Correo Electronico</label>
<input asp-for="Email" class="form-control" type="email" required placeholder="alguien@dominio.com" />
<input asp-for="Email" class="form-control" maxlength="75" type="email" required placeholder="alguien@dominio.com" />
<div class="text-danger">@Html.ValidationMessage("Email")</div>
</div>
<div class="form-group">
<label asp-for="Password">Contraseña</label>
<input asp-for="Password" class="form-control" type="password" required minlength="8" />
<input asp-for="Password" class="form-control" maxlength="255" type="password" required minlength="8" />
<span class="text-danger"></span>
</div>
<button type="submit" class="btn" asp-controller="Home" id="createButton" asp-action="Register">Crear</button>
Expand Down
2 changes: 1 addition & 1 deletion Views/Home/Ticket.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>
<div class="form-group Affair">
<label for="Affair">Mensaje</label>
<textarea id="Affair" asp-for="Affair" rows="5" class="input" placeholder="Ingresa tu mensaje"></textarea>
<textarea id="Affair" asp-for="Affair" maxlength="1024" rows="5" class="input" placeholder="Ingresa tu mensaje"></textarea>
</div>
<div class="submit">
<button type="submit" class="btn submit">Enviar</button>
Expand Down
4 changes: 2 additions & 2 deletions Views/Picture/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</head>
<div class="body">
<h1>Detalles de imagen</h1>
<h2>@Model.Name</h2>
<h2 class="name">@Model.Name</h2>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -52,7 +52,7 @@
<p>@Model.PlaceId - @Model.PlaceName</p>
}
</td>
<td>
<td class="link">
<p>@Model.Link</p>
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions Views/Picture/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
@foreach (var item in Model)
{
<tr>
<td>
<td class="name">
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
<td class="link">
@Html.DisplayFor(modelItem => item.Link)
</td>
<td class="acciones">
Expand Down
81 changes: 49 additions & 32 deletions Views/Place/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group input-container">
<label class="control-label">Nombre</label>
<input asp-for="NamePlace" required maxlength="80" class="form-control" />
<input asp-for="NamePlace" required maxlength="128" class="form-control" />
<span asp-validation-for="NamePlace" class="text-danger"></span>
</div>
<div class="form-group input-container">
Expand Down Expand Up @@ -84,40 +84,57 @@
</form>
</div>
<script>
$('#createButton').click(function (e) {
e.preventDefault();
$('#createButton').click(function (e) {
e.preventDefault();
// Manually check if fields meet requirements
var name = $('#NamePlace').val();
var latitude = $('#Latitude').val();
var longitude = $('#Longitude').val();
var address = $('#Address').val();
var description = $('#Description').val();
var link = $('#Link').val();
var name = $('#NamePlace').val();
var latitude = $('#Latitude').val();
var longitude = $('#Longitude').val();
var address = $('#Address').val();
var description = $('#Description').val();
var link = $('#Link').val();
if (name.trim() === '' || latitude.trim() === '' || longitude.trim() === '' || address.trim() === '' || description.trim() === '' || link.trim() === '') {
if (name.trim() === '' || latitude.trim() === '' || longitude.trim() === '' || address.trim() === '' || description.trim() === '' || link.trim() === '') {
// Show an error message if any field is empty
Swal.fire({
title: 'Error',
text: 'Por favor, completa todos los campos obligatorios.',
icon: 'error'
});
} else {
Swal.fire({
title: 'Error',
text: 'Por favor, completa todos los campos obligatorios.',
icon: 'error'
});
} else {
// If all fields are complete, show confirmation
Swal.fire({
title: '¿Estás seguro?',
text: '¿Deseas crear este lugar?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Sí, crear lugar',
cancelButtonText: 'Cancelar'
}).then((result) => {
if (result.isConfirmed) {
$('form').submit();
}
});
}
});
Swal.fire({
title: '¿Estás seguro?',
text: '¿Deseas crear este lugar?',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Sí, crear lugar',
cancelButtonText: 'Cancelar'
}).then((result) => {
if (result.isConfirmed) {
$('form').submit();
}
});
}
});
document.getElementById('latitudeInput').addEventListener('input', function (e) {
// Elimina todos los caracteres que no sean dígitos o un punto decimal
this.value = this.value.replace(/[^0-9.]/g, '');
// Si el valor tiene más de un punto decimal, elimina el segundo
if ((this.value.match(/\./g) || []).length > 1) {
this.value = this.value.slice(0, -1);
}
// Limita la longitud del valor a 20 caracteres
if (this.value.length > 20) {
this.value = this.value.slice(0, 20);
}
});
</script>
20 changes: 10 additions & 10 deletions Views/Place/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,28 @@
</thead>
<tbody>
<tr>
<td>
<p>
<td class="name">

@Html.DisplayFor(model => model.NamePlace)
</p>

</td>
<td>
<p>
@Html.DisplayFor(model => model.Latitude),
@Html.DisplayFor(model => model.Longitude)
</p>
</td>
<td>
<p>
<td class="direccion">

@Html.DisplayFor(model => model.Address)
</p>

</td>
<td>
<p>
<td class="descripcion">

@Html.DisplayFor(model => model.Description)
</p>

</td>
<td>
<td class="enlace">
<p>
@Html.DisplayFor(model => model.Link)
</p>
Expand Down
4 changes: 2 additions & 2 deletions Views/Place/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
@Html.DisplayFor(modelItem => item.Latitude),
@Html.DisplayFor(modelItem => item.Longitude)
</td>
<td>
<td class="direccion">
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
<td class="descripcion">
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion Views/Role/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group input-container">
<label class="control-label">Nombre</label>
<input asp-for="NameRole" class="form-control" />
<input asp-for="NameRole" maxlength="50" class="form-control" />
<span asp-validation-for="NameRole" class="text-danger"></span>
</div>
<div class="form-group submit">
Expand Down
2 changes: 1 addition & 1 deletion Views/Role/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<input type="submit" value="Guardar" asp-action="Edit" id="saveButton" class="btn" />
</div>
<div class="backk">
<a asp-action="Index" class="back">Back to List</a>
<a asp-action="Index" class="back">Volver a lista</a>
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion Views/Shared/_LayoutAdmin.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<li><a asp-controller="Place" asp-action="Index">Lugares</a></li>
<li><a asp-controller="Review" asp-action="Index">Reseñas</a></li>
<li><a asp-controller="Role" asp-action="Index">Roles</a></li>
<li><a asp-controller="Ticket" asp-action="Index">Tickets</a></li>
<li><a asp-controller="Ticket" asp-action="Index" asp-route-filter="All">Tickets</a></li>
<li><a asp-controller="Account" asp-action="Index">Usuarios</a></li>
</ul>
</li>
Expand Down
2 changes: 1 addition & 1 deletion Views/Shared/_LayoutEditor.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<li><a asp-controller="Picture" asp-action="Index">Imagenes</a></li>
<li><a asp-controller="Place" asp-action="Index">Lugares</a></li>
<li><a asp-controller="Review" asp-action="Index">Reseñas</a></li>
<li><a asp-controller="Ticket" asp-action="Index">Tickets</a></li>
<li><a asp-controller="Ticket" asp-action="Index" asp-route-filter="All">Tickets</a></li>
</ul>
</li>
<li><a asp-controller="Map" asp-action="Activities">Actividades</a></li>
Expand Down
4 changes: 2 additions & 2 deletions Views/State/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group input-container">
<label class="control-label">Nombre</label>
<input asp-for="NameState" required class="form-control" />
<input asp-for="NameState" maxlength="30" required class="form-control" />
<span asp-validation-for="NameState" class="text-danger"></span>
</div>
<div class="form-group input-container">
<label class="control-label">Tabla</label>
<input asp-for="Table" class="form-control" />
<input asp-for="Table" maxlength="20" class="form-control" />
<span asp-validation-for="Table" class="tdext-danger"></span>
</div>
<div class="form-group submit">
Expand Down
Loading

0 comments on commit b40ada2

Please sign in to comment.