Update UI Blazor Add Customers
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 4m55s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 4m55s
This commit is contained in:
parent
650650b9a6
commit
559de37672
@ -32,6 +32,5 @@ namespace Domain.Entities
|
||||
|
||||
public virtual ICollection<ECustomerDocument> PhSCustomerDocuments { get; set; } = new List<ECustomerDocument>();
|
||||
|
||||
//public virtual ICollection<PhSQuoteHeader> PhSQuoteHeaders { get; set; } = new List<PhSQuoteHeader>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
using Domain.Generics;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Models.Helpers
|
||||
{
|
||||
|
||||
10
phronCare.UIBlazor/Data/PagedResult.cs
Normal file
10
phronCare.UIBlazor/Data/PagedResult.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace phronCare.UIBlazor.Data
|
||||
{
|
||||
public class PagedResult<T>
|
||||
{
|
||||
public IEnumerable<T> Items { get; set; }
|
||||
public int TotalItems { get; set; }
|
||||
public int Page { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
}
|
||||
}
|
||||
113
phronCare.UIBlazor/Pages/Sales/Customers.razor
Normal file
113
phronCare.UIBlazor/Pages/Sales/Customers.razor
Normal file
@ -0,0 +1,113 @@
|
||||
@page "/customers"
|
||||
@using phronCare.UIBlazor.Services.Sales
|
||||
@using phronCare.UIBlazor.Data
|
||||
|
||||
|
||||
@inject CustomerHttpService CustomerService
|
||||
|
||||
<h3 class="text-xl font-bold mb-4">Buscar Clientes</h3>
|
||||
|
||||
<div class="mb-4 space-y-2">
|
||||
<input @bind="SearchParams.Name" placeholder="Nombre" class="border rounded p-1 w-full" />
|
||||
<input @bind="SearchParams.Email" placeholder="Email" class="border rounded p-1 w-full" />
|
||||
<input @bind="SearchParams.Document" placeholder="Documento" class="border rounded p-1 w-full" />
|
||||
<button class="bg-blue-500 text-white px-4 py-2 rounded" @onclick="BuscarClientes">Buscar</button>
|
||||
</div>
|
||||
|
||||
@if (PagedResult != null)
|
||||
{
|
||||
<table class="table-auto w-full border">
|
||||
<thead>
|
||||
<tr class="bg-gray-200">
|
||||
<th class="px-2 py-1">Id</th>
|
||||
<th>Name</th>
|
||||
<th>BusinessName</th>
|
||||
<th>Active</th>
|
||||
<th>ExternalCode</th>
|
||||
<th>HasCreditAccount</th>
|
||||
<th>CreditLimit</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th>Dirección</th>
|
||||
<th>Documento</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var c in PagedResult.Items)
|
||||
{
|
||||
var addr = c.PhSCustomerAddresses.FirstOrDefault();
|
||||
var doc = c.PhSCustomerDocuments.FirstOrDefault();
|
||||
<tr class="border-b">
|
||||
<td>@c.Id</td>
|
||||
<td>@c.Name</td>
|
||||
<td>@c.BusinessName</td>
|
||||
<td>@(c.Active ? "Sí" : "No")</td>
|
||||
<td>@c.ExternalCode</td>
|
||||
<td>@(c.HasCreditAccount ? "Sí" : "No")</td>
|
||||
<td>@c.CreditLimit</td>
|
||||
<td>@addr?.Email</td>
|
||||
<td>@addr?.Phonenumber</td>
|
||||
<td>
|
||||
@addr?.Streetaddress1 @addr?.Streetaddress2 <br />
|
||||
@addr?.City, @addr?.Postalcode, @addr?.Country
|
||||
</td>
|
||||
<td>
|
||||
@doc?.DocumentNumber <br />
|
||||
@doc?.IssueDate?.ToString("yyyy-MM-dd") <br />
|
||||
@doc?.ExpiryDate?.ToString("yyyy-MM-dd")
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="mt-4 flex justify-between items-center">
|
||||
<button class="bg-gray-300 px-4 py-2 rounded" @onclick="AnteriorPagina" disabled="@(!PuedeRetroceder)">Anterior</button>
|
||||
<span>Página @SearchParams.Page de @TotalPaginas</span>
|
||||
<button class="bg-gray-300 px-4 py-2 rounded" @onclick="SiguientePagina" disabled="@(!PuedeAvanzar)">Siguiente</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No hay resultados.</p>
|
||||
}
|
||||
|
||||
@code {
|
||||
private CustomerSearchParams SearchParams = new();
|
||||
private PagedResult<ECustomer>? PagedResult;
|
||||
|
||||
private async Task BuscarClientes()
|
||||
{
|
||||
SearchParams.Page = 1; // reset al buscar
|
||||
await CargarClientes();
|
||||
}
|
||||
|
||||
private async Task CargarClientes()
|
||||
{
|
||||
// pagedResult = await CustomerHttpService.searcs(SearchParams);
|
||||
}
|
||||
|
||||
private async Task SiguientePagina()
|
||||
{
|
||||
if (PuedeAvanzar)
|
||||
{
|
||||
SearchParams.Page++;
|
||||
await CargarClientes();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AnteriorPagina()
|
||||
{
|
||||
if (PuedeRetroceder)
|
||||
{
|
||||
SearchParams.Page--;
|
||||
await CargarClientes();
|
||||
}
|
||||
}
|
||||
|
||||
private int TotalPaginas => PagedResult is null ? 1 :
|
||||
(int)Math.Ceiling((double)(PagedResult.TotalItems) / SearchParams.PageSize);
|
||||
|
||||
private bool PuedeAvanzar => PagedResult != null && SearchParams.Page < TotalPaginas;
|
||||
private bool PuedeRetroceder => PagedResult != null && SearchParams.Page > 1;
|
||||
}
|
||||
@ -8,6 +8,7 @@ using Blazored.Modal;
|
||||
using Blazored.Toast;
|
||||
using phronCare.UIBlazor.Services.Tickets;
|
||||
using phronCare.UIBlazor.Shared;
|
||||
using phronCare.UIBlazor.Services.Sales;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
builder.RootComponents.Add<App>("#app");
|
||||
@ -38,6 +39,7 @@ if (config != null)
|
||||
#endregion
|
||||
#region Injection Dependencis
|
||||
builder.Services.AddScoped<TicketsService>();
|
||||
builder.Services.AddScoped<CustomerHttpService>();
|
||||
#endregion
|
||||
#region UI
|
||||
builder.Services.AddBlazoredModal();
|
||||
|
||||
25
phronCare.UIBlazor/Services/Sales/CustomerHttpService.cs
Normal file
25
phronCare.UIBlazor/Services/Sales/CustomerHttpService.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Domain.Entities;
|
||||
using Domain.Generics;
|
||||
using System.Net.Http.Json;
|
||||
namespace phronCare.UIBlazor.Services.Sales
|
||||
{
|
||||
public class CustomerHttpService
|
||||
{
|
||||
private readonly HttpClient _http;
|
||||
public CustomerHttpService(HttpClient http)
|
||||
{
|
||||
_http = http;
|
||||
}
|
||||
public async Task<PagedResult<ECustomer>?> SearchCustomersAsync(CustomerSearchParams searchParams)
|
||||
{
|
||||
var url = $"api/Customer/SearchPaged?" +
|
||||
$"name={searchParams.Name}&" +
|
||||
$"email={searchParams.Email}&" +
|
||||
$"document={searchParams.Document}&" +
|
||||
$"page={searchParams.Page}&" +
|
||||
$"pageSize={searchParams.PageSize}";
|
||||
return await _http.GetFromJsonAsync<PagedResult<ECustomer>>(url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
phronCare.UIBlazor/Services/Sales/CustomerSearchParams.cs
Normal file
11
phronCare.UIBlazor/Services/Sales/CustomerSearchParams.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace phronCare.UIBlazor.Services.Sales
|
||||
{
|
||||
public class CustomerSearchParams
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Document { get; set; }
|
||||
public int Page { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 10;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user