Add Fields in CustomerForm and new Services
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m41s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m41s
This commit is contained in:
parent
ee126d074c
commit
8271d399f4
@ -1,43 +1,74 @@
|
||||
@page "/sales/customerform"
|
||||
@page "/sales/customerform/{CustomerId:int}"
|
||||
@using phronCare.UIBlazor.Services.Sales
|
||||
|
||||
@inject HttpClient _httpClient
|
||||
@inject NavigationManager Navigation
|
||||
@inject IToastService toastService
|
||||
@inject AuthenticationStateProvider authenticationStateProvider
|
||||
@inject AccountTypeService accountTypeService
|
||||
@inject TaxConditionService taxConditionService
|
||||
|
||||
|
||||
<EditForm Model="@customer" OnValidSubmit="@HandleValidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="Name">Razón Social:</label>
|
||||
<div class="col-md-6">
|
||||
<label for="Name">Nombre / Razón Social:</label>
|
||||
<InputText id="Name" @bind-Value="customer.Name" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="BusinessName">Sucursal / Nombre Comercial:</label>
|
||||
<InputText id="BusinessName" @bind-Value="customer.BusinessName" class="form-control" />
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label for="AccountTypeId">Tipo de Cuenta:</label>
|
||||
<InputSelect id="AccountTypeId" @bind-Value="customer.AccounttypesId" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label for="AccounttypesId">Tipo de Cuenta:</label>
|
||||
<InputSelect id="AccounttypesId" @bind-Value="customer.AccounttypesId" class="form-control">
|
||||
<option value="">-- Seleccionar --</option>
|
||||
@foreach (var type in accountTypes)
|
||||
{
|
||||
<option value="@type.Id">@type.Name</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="TaxConditionId">Condición Fiscal:</label>
|
||||
<InputSelect id="TaxConditionId" @bind-Value="customer.TaxConditionId" class="form-control">
|
||||
<option value="">-- Seleccionar --</option>
|
||||
@foreach (var tax in taxConditions)
|
||||
{
|
||||
<option value="@tax.Id">@tax.Description</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Acá van documentos y direcciones (lo agregamos más adelante) -->
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<label for="HasCreditAccount">¿Cuenta Corriente?</label><br />
|
||||
<InputCheckbox id="HasCreditAccount" @bind-Value="customer.HasCreditAccount" />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="CreditLimit">Límite de Crédito:</label>
|
||||
<InputNumber id="CreditLimit" @bind-Value="customer.CreditLimit" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="Active">Activo:</label><br />
|
||||
<InputCheckbox id="Active" @bind-Value="customer.Active" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Guardar</button>
|
||||
<button type="button" class="btn btn-secondary" @onclick="Cancel">Volver</button>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label for="ExternalCode">Código Externo (opcional):</label>
|
||||
<InputText id="ExternalCode" @bind-Value="customer.ExternalCode" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</EditForm>
|
||||
|
||||
@code {
|
||||
@ -46,13 +77,14 @@
|
||||
|
||||
private ECustomer customer { get; set; } = new();
|
||||
private List<EAccountType> accountTypes = new();
|
||||
private List<ETaxCondition> taxConditions = new();
|
||||
|
||||
private string returnUrl = "/sales/customers";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadAccountTypes();
|
||||
|
||||
await LoadTaxConditions();
|
||||
if (CustomerId.HasValue)
|
||||
{
|
||||
// Cargar datos del cliente existente desde la API
|
||||
@ -62,8 +94,12 @@
|
||||
|
||||
private async Task LoadAccountTypes()
|
||||
{
|
||||
var result = await _httpClient.GetFromJsonAsync<List<EAccountType>>("/api/AccountType/GetAll");
|
||||
accountTypes = result ?? new();
|
||||
accountTypes = await accountTypeService.GetAllAsync();
|
||||
}
|
||||
|
||||
private async Task LoadTaxConditions()
|
||||
{
|
||||
taxConditions = await taxConditionService.GetAllAsync();
|
||||
}
|
||||
|
||||
private async Task HandleValidSubmit()
|
||||
|
||||
@ -4,9 +4,7 @@
|
||||
@using Domain.Entities
|
||||
@using Domain.Generics
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@inject CustomerHttpService CustomerService
|
||||
|
||||
@inject CustomerService customerService
|
||||
|
||||
<div class="card " style="zoom:90%">
|
||||
<div class="card-header">
|
||||
@ -73,7 +71,7 @@
|
||||
|
||||
private async Task CargarClientes()
|
||||
{
|
||||
PagedResult = await CustomerService.SearchCustomersAsync(SearchParams);
|
||||
PagedResult = await customerService.SearchCustomersAsync(SearchParams);
|
||||
if (PagedResult?.Items is not null)
|
||||
{
|
||||
TablaClientes = PagedResult.Items.Select(c =>
|
||||
|
||||
@ -39,7 +39,9 @@ if (config != null)
|
||||
#endregion
|
||||
#region Injection Dependencis
|
||||
builder.Services.AddScoped<TicketsService>();
|
||||
builder.Services.AddScoped<CustomerHttpService>();
|
||||
builder.Services.AddScoped<CustomerService>();
|
||||
builder.Services.AddScoped<TaxConditionService>();
|
||||
builder.Services.AddScoped<AccountTypeService>();
|
||||
#endregion
|
||||
#region UI
|
||||
builder.Services.AddBlazoredModal();
|
||||
|
||||
21
phronCare.UIBlazor/Services/Sales/AccountTypeService .cs
Normal file
21
phronCare.UIBlazor/Services/Sales/AccountTypeService .cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Domain.Entities;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace phronCare.UIBlazor.Services.Sales
|
||||
{
|
||||
public class AccountTypeService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public AccountTypeService(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public async Task<List<EAccountType>> GetAllAsync()
|
||||
{
|
||||
var result = await _httpClient.GetFromJsonAsync<List<EAccountType>>("/api/AccountType/GetAll");
|
||||
return result ?? new List<EAccountType>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
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/search?" +
|
||||
$"name={searchParams.Name}&" +
|
||||
$"email={searchParams.Email}&" +
|
||||
$"document={searchParams.Document}&" +
|
||||
$"page={searchParams.Page}&" +
|
||||
$"pageSize={searchParams.PageSize}";
|
||||
return await _http.GetFromJsonAsync<PagedResult<ECustomer>>(url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,32 @@
|
||||
namespace phronCare.UIBlazor.Services.Sales
|
||||
using Domain.Entities;
|
||||
using Domain.Generics;
|
||||
using System.Net.Http.Json;
|
||||
namespace phronCare.UIBlazor.Services.Sales
|
||||
{
|
||||
public class CustomerService
|
||||
{
|
||||
private readonly HttpClient _http;
|
||||
public CustomerService(HttpClient http)
|
||||
{
|
||||
_http = http;
|
||||
}
|
||||
public async Task<PagedResult<ECustomer>?> SearchCustomersAsync(CustomerSearchParams searchParams)
|
||||
{
|
||||
var url = $"api/Customer/search?" +
|
||||
$"name={searchParams.Name}&" +
|
||||
$"email={searchParams.Email}&" +
|
||||
$"document={searchParams.Document}&" +
|
||||
$"page={searchParams.Page}&" +
|
||||
$"pageSize={searchParams.PageSize}";
|
||||
return await _http.GetFromJsonAsync<PagedResult<ECustomer>>(url);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
21
phronCare.UIBlazor/Services/Sales/TaxConditionService.cs
Normal file
21
phronCare.UIBlazor/Services/Sales/TaxConditionService.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Domain.Entities;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace phronCare.UIBlazor.Services.Sales
|
||||
{
|
||||
public class TaxConditionService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public TaxConditionService(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public async Task<List<ETaxCondition>> GetAllAsync()
|
||||
{
|
||||
var result = await _httpClient.GetFromJsonAsync<List<ETaxCondition>>("/api/TaxCondition/GetAll");
|
||||
return result ?? new List<ETaxCondition>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user