diff --git a/phronCare.UIBlazor/Pages/Sales/CustomerForm.razor b/phronCare.UIBlazor/Pages/Sales/CustomerForm.razor index 5c55151..c2605a8 100644 --- a/phronCare.UIBlazor/Pages/Sales/CustomerForm.razor +++ b/phronCare.UIBlazor/Pages/Sales/CustomerForm.razor @@ -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 + +
+
+ + +
+
+ + +
+
-
-
- - -
+
+ + + + @foreach (var type in accountTypes) + { + + } +
-
-
- - - @foreach (var type in accountTypes) - { - - } - -
+
+ + + + @foreach (var tax in taxConditions) + { + + } +
- - -
-
- - +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+ @code { @@ -46,13 +77,14 @@ private ECustomer customer { get; set; } = new(); private List accountTypes = new(); + private List 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>("/api/AccountType/GetAll"); - accountTypes = result ?? new(); + accountTypes = await accountTypeService.GetAllAsync(); + } + + private async Task LoadTaxConditions() + { + taxConditions = await taxConditionService.GetAllAsync(); } private async Task HandleValidSubmit() diff --git a/phronCare.UIBlazor/Pages/Sales/Customers.razor b/phronCare.UIBlazor/Pages/Sales/Customers.razor index 6746331..3897a8d 100644 --- a/phronCare.UIBlazor/Pages/Sales/Customers.razor +++ b/phronCare.UIBlazor/Pages/Sales/Customers.razor @@ -4,9 +4,7 @@ @using Domain.Entities @using Domain.Generics @inject NavigationManager Navigation - -@inject CustomerHttpService CustomerService - +@inject CustomerService customerService
@@ -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 => diff --git a/phronCare.UIBlazor/Program.cs b/phronCare.UIBlazor/Program.cs index b71fd6e..ea5c9a5 100644 --- a/phronCare.UIBlazor/Program.cs +++ b/phronCare.UIBlazor/Program.cs @@ -39,7 +39,9 @@ if (config != null) #endregion #region Injection Dependencis builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); #endregion #region UI builder.Services.AddBlazoredModal(); diff --git a/phronCare.UIBlazor/Services/Sales/AccountTypeService .cs b/phronCare.UIBlazor/Services/Sales/AccountTypeService .cs new file mode 100644 index 0000000..69aa7dc --- /dev/null +++ b/phronCare.UIBlazor/Services/Sales/AccountTypeService .cs @@ -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> GetAllAsync() + { + var result = await _httpClient.GetFromJsonAsync>("/api/AccountType/GetAll"); + return result ?? new List(); + } + } +} diff --git a/phronCare.UIBlazor/Services/Sales/CustomerHttpService.cs b/phronCare.UIBlazor/Services/Sales/CustomerHttpService.cs deleted file mode 100644 index b064a58..0000000 --- a/phronCare.UIBlazor/Services/Sales/CustomerHttpService.cs +++ /dev/null @@ -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?> 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>(url); - } - } - -} diff --git a/phronCare.UIBlazor/Services/Sales/CustomerSearchParams.cs b/phronCare.UIBlazor/Services/Sales/CustomerSearchParams.cs deleted file mode 100644 index 495bb06..0000000 --- a/phronCare.UIBlazor/Services/Sales/CustomerSearchParams.cs +++ /dev/null @@ -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; - } -} diff --git a/phronCare.UIBlazor/Services/Sales/CustomerService.cs b/phronCare.UIBlazor/Services/Sales/CustomerService.cs index 610bb29..78f6cdc 100644 --- a/phronCare.UIBlazor/Services/Sales/CustomerService.cs +++ b/phronCare.UIBlazor/Services/Sales/CustomerService.cs @@ -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?> 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>(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; } } diff --git a/phronCare.UIBlazor/Services/Sales/TaxConditionService.cs b/phronCare.UIBlazor/Services/Sales/TaxConditionService.cs new file mode 100644 index 0000000..69fa226 --- /dev/null +++ b/phronCare.UIBlazor/Services/Sales/TaxConditionService.cs @@ -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> GetAllAsync() + { + var result = await _httpClient.GetFromJsonAsync>("/api/TaxCondition/GetAll"); + return result ?? new List(); + } + } +}