diff --git a/Core/Services/PatientService.cs b/Core/Services/PatientService.cs index 7293ab5..f374140 100644 --- a/Core/Services/PatientService.cs +++ b/Core/Services/PatientService.cs @@ -6,122 +6,125 @@ using Models.Interfaces; using System.Reflection; using Transversal.Services; -public class PatientService : IPatientDom +namespace Core.Services { - #region Declaraciones y Constructor - private readonly IPhSPatientRepository _repository; - public PatientService(IPhSPatientRepository patientRepository) + public class PatientService : IPatientDom { - _repository = patientRepository ?? throw new ArgumentNullException(nameof(patientRepository)); - } - #endregion - #region Métodos de servicio - public async Task> GetAllAsync(int page = 1, int pageSize = 50) - { - try + #region Declaraciones y Constructor + private readonly IPhSPatientRepository _repository; + public PatientService(IPhSPatientRepository patientRepository) { - return await _repository.GetAllAsync(page, pageSize); + _repository = patientRepository ?? throw new ArgumentNullException(nameof(patientRepository)); } - catch (Exception ex) + #endregion + #region Métodos de servicio + public async Task> GetAllAsync(int page = 1, int pageSize = 50) { - var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; - throw new Exception($"{methodName} Message: {ex.Message}", ex); - } - } - public async Task GetByIdAsync(int id) - { - try - { - return await _repository.GetByIdAsync(id); - } - catch (Exception ex) - { - var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; - throw new Exception($"{methodName} Message: {ex.Message}", ex); - } - } - public async Task CreateAsync(EPatient entity) - { - if (entity is null) - throw new ArgumentNullException(nameof(entity), "El paciente no puede ser nulo."); - - if (string.IsNullOrWhiteSpace(entity.Firstname) || string.IsNullOrWhiteSpace(entity.Lastname)) - throw new ArgumentException("Debe completar el nombre y apellido del paciente."); - - if (string.IsNullOrWhiteSpace(entity.DocumentNumber)) - throw new ArgumentException("Debe completar el número de documento del paciente."); - - return await _repository.CreateAsync(entity); - } - public async Task UpdateAsync(EPatient entity) - { - if (entity is null) - throw new ArgumentNullException(nameof(entity), "El paciente no puede ser nulo."); - - if (string.IsNullOrWhiteSpace(entity.Firstname) || string.IsNullOrWhiteSpace(entity.Lastname)) - throw new ArgumentException("Debe completar el nombre y apellido del paciente."); - - if (string.IsNullOrWhiteSpace(entity.DocumentNumber)) - throw new ArgumentException("Debe completar el número de documento del paciente."); - - return await _repository.UpdateAsync(entity); - } - public async Task> SearchAsync(string? name, string? document, int page = 1, int pageSize = 50) - { - try - { - return await _repository.SearchAsync(name, document, page, pageSize); - } - catch (Exception ex) - { - var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; - throw new Exception($"{methodName} Message: {ex.Message}", ex); - } - } - public Task DeleteAsync(int id) - { - // Implementar según políticas del sistema (soft delete, etc.) - throw new NotImplementedException(); - } - public async Task ExportFilteredPatientsToExcelAsync(PatientSearchParams searchParams) - { - try - { - var searchResult = await SearchAsync( - searchParams.Name, - searchParams.Document, - searchParams.Page, - searchParams.PageSize - ); - - if (searchResult?.Items is null || !searchResult.Items.Any()) + try { - throw new Exception("No se encontraron pacientes para exportar."); + return await _repository.GetAllAsync(page, pageSize); } - - var stream = new XLSXExportBase(); - - var patientData = searchResult.Items.Select(p => new + catch (Exception ex) { - p.Id, - p.Firstname, - p.Lastname, - p.DocumentNumber, - p.AffiliateNumber, - p.Email, - p.Phone, - p.Birthdate, - p.Gender - }).ToList(); - - var excelFile = stream.ExportExcel(patientData); - return excelFile; + var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; + throw new Exception($"{methodName} Message: {ex.Message}", ex); + } } - catch (Exception ex) + public async Task GetByIdAsync(int id) { - var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; - throw new Exception($"{methodName} - Error al exportar pacientes: {ex.Message}", ex); + try + { + return await _repository.GetByIdAsync(id); + } + catch (Exception ex) + { + var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; + throw new Exception($"{methodName} Message: {ex.Message}", ex); + } } + public async Task CreateAsync(EPatient entity) + { + if (entity is null) + throw new ArgumentNullException(nameof(entity), "El paciente no puede ser nulo."); + + if (string.IsNullOrWhiteSpace(entity.Firstname) || string.IsNullOrWhiteSpace(entity.Lastname)) + throw new ArgumentException("Debe completar el nombre y apellido del paciente."); + + if (string.IsNullOrWhiteSpace(entity.DocumentNumber)) + throw new ArgumentException("Debe completar el número de documento del paciente."); + + return await _repository.CreateAsync(entity); + } + public async Task UpdateAsync(EPatient entity) + { + if (entity is null) + throw new ArgumentNullException(nameof(entity), "El paciente no puede ser nulo."); + + if (string.IsNullOrWhiteSpace(entity.Firstname) || string.IsNullOrWhiteSpace(entity.Lastname)) + throw new ArgumentException("Debe completar el nombre y apellido del paciente."); + + if (string.IsNullOrWhiteSpace(entity.DocumentNumber)) + throw new ArgumentException("Debe completar el número de documento del paciente."); + + return await _repository.UpdateAsync(entity); + } + public async Task> SearchAsync(string? name, string? document, int page = 1, int pageSize = 50) + { + try + { + return await _repository.SearchAsync(name, document, page, pageSize); + } + catch (Exception ex) + { + var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; + throw new Exception($"{methodName} Message: {ex.Message}", ex); + } + } + public Task DeleteAsync(int id) + { + // Implementar según políticas del sistema (soft delete, etc.) + throw new NotImplementedException(); + } + public async Task ExportFilteredPatientsToExcelAsync(PatientSearchParams searchParams) + { + try + { + var searchResult = await SearchAsync( + searchParams.Name, + searchParams.Document, + searchParams.Page, + searchParams.PageSize + ); + + if (searchResult?.Items is null || !searchResult.Items.Any()) + { + throw new Exception("No se encontraron pacientes para exportar."); + } + + var stream = new XLSXExportBase(); + + var patientData = searchResult.Items.Select(p => new + { + p.Id, + p.Firstname, + p.Lastname, + p.DocumentNumber, + p.AffiliateNumber, + p.Email, + p.Phone, + p.Birthdate, + p.Gender + }).ToList(); + + var excelFile = stream.ExportExcel(patientData); + return excelFile; + } + catch (Exception ex) + { + var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod"; + throw new Exception($"{methodName} - Error al exportar pacientes: {ex.Message}", ex); + } + } + #endregion } - #endregion -} +} \ No newline at end of file diff --git a/Core/Services/QuoteService.cs b/Core/Services/QuoteService.cs index b458cb3..818f4e1 100644 --- a/Core/Services/QuoteService.cs +++ b/Core/Services/QuoteService.cs @@ -5,7 +5,7 @@ using Models.Interfaces; using System.Reflection; using Transversal.Services; -namespace PhronCare.Core.Services.Sales +namespace Core.Services { public class QuoteService( IPhSQuoteHeaderRepository quoteHeaderRepository, diff --git a/Models/Repositories/PhSFormSeriesRepository.cs b/Models/Repositories/PhSFormSeriesRepository.cs index 34fae70..bd45a3b 100644 --- a/Models/Repositories/PhSFormSeriesRepository.cs +++ b/Models/Repositories/PhSFormSeriesRepository.cs @@ -2,7 +2,7 @@ using Models.Interfaces; using Models.Models; -namespace PhronCare.Core.Data.Repositories.Sales +namespace Models.Repositories { public class PhSFormSeriesRepository(PhronCareOperationsHubContext context) : IPhSFormSeriesRepository { diff --git a/Models/Repositories/PhSPatientRepository .cs b/Models/Repositories/PhSPatientRepository .cs index 7df8973..af3fde6 100644 --- a/Models/Repositories/PhSPatientRepository .cs +++ b/Models/Repositories/PhSPatientRepository .cs @@ -6,7 +6,7 @@ using Models.Helpers; using Models.Interfaces; using Models.Models; -namespace Infrastructure.Repositories.Patients +namespace Models.Repositories { public class PhSPatientRepository(PhronCareOperationsHubContext context, ILogger logger) : IPhSPatientRepository { diff --git a/Models/Repositories/PhSPeopleRepository.cs b/Models/Repositories/PhSPeopleRepository.cs index 2b97676..451b10c 100644 --- a/Models/Repositories/PhSPeopleRepository.cs +++ b/Models/Repositories/PhSPeopleRepository.cs @@ -6,7 +6,7 @@ using Models.Helpers; using Models.Interfaces; using Models.Models; -namespace PhronCare.Core.Data.Repositories.Sales +namespace Models.Repositories { public class PhSPeopleRepository(PhronCareOperationsHubContext context) : IPhSPeopleRepository { diff --git a/Models/Repositories/PhSQuoteDetailRepository.cs b/Models/Repositories/PhSQuoteDetailRepository.cs index d34dcc2..6a7d105 100644 --- a/Models/Repositories/PhSQuoteDetailRepository.cs +++ b/Models/Repositories/PhSQuoteDetailRepository.cs @@ -5,7 +5,7 @@ using Models.Helpers; using Models.Interfaces; using Models.Models; -namespace PhronCare.Core.Data.Repositories.Sales +namespace Models.Repositories { public class PhSQuoteDetailRepository(PhronCareOperationsHubContext context) : IPhSQuoteDetailRepository { diff --git a/Models/Repositories/PhSQuoteHeaderRepository.cs b/Models/Repositories/PhSQuoteHeaderRepository.cs index 01cec70..74f0970 100644 --- a/Models/Repositories/PhSQuoteHeaderRepository.cs +++ b/Models/Repositories/PhSQuoteHeaderRepository.cs @@ -5,7 +5,7 @@ using Models.Models; using Domain.Entities; using Domain.Generics; -namespace PhronCare.Core.Data.Repositories.Sales +namespace Models.Repositories { public class PhSQuoteHeaderRepository(PhronCareOperationsHubContext context) : IPhSQuoteHeaderRepository { diff --git a/Models/Repositories/PhSQuoteRoleRepository.cs b/Models/Repositories/PhSQuoteRoleRepository.cs index 9e026cf..bbed731 100644 --- a/Models/Repositories/PhSQuoteRoleRepository.cs +++ b/Models/Repositories/PhSQuoteRoleRepository.cs @@ -5,7 +5,7 @@ using Models.Helpers; using Models.Interfaces; using Models.Models; -namespace PhronCare.Core.Data.Repositories.Sales +namespace Models.Repositories { public class PhSQuoteRoleRepository(PhronCareOperationsHubContext context) : IPhSQuoteRoleRepository { diff --git a/phronCare.API/Models/Seurity/ApplicationUser.cs b/phronCare.API/Models/Security/ApplicationUser.cs similarity index 100% rename from phronCare.API/Models/Seurity/ApplicationUser.cs rename to phronCare.API/Models/Security/ApplicationUser.cs diff --git a/phronCare.API/Program.cs b/phronCare.API/Program.cs index dd6d753..15038b6 100644 --- a/phronCare.API/Program.cs +++ b/phronCare.API/Program.cs @@ -11,14 +11,10 @@ using Services.Interfaces; using Services.Services; using Services.Models; using System.Text; -using Infrastructure.Repositories.Patients; -using PhronCare.Core.Data.Repositories.Sales; -using PhronCare.Core.Services.Sales; -using phronCare.API.Models.Security; using phronCare.API.Models; using Core.Interfaces; using Core.Services; -using System.Net.Http.Headers; +using phronCare.API.Models.Security; var builder = WebApplication.CreateBuilder(args); @@ -37,7 +33,6 @@ builder.Services.AddDbContext(options => #region Repositorios y Servicios RepositorysAndServices(builder); - #endregion #region Require Confirmed Email @@ -55,16 +50,7 @@ builder.Services.Configure(opts => builder.Services.AddSingleton(); #endregion -//#region Security Identity EF Configuration -//builder.Services.AddIdentity() -// .AddEntityFrameworkStores() -// .AddDefaultTokenProviders(); -//builder.Services.Configure( opts => opts.TokenLifespan=TimeSpan.FromHours(10)); -//builder.Services.AddSingleton(); -//#endregion - #region Authentication Service - builder.Services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; @@ -142,16 +128,8 @@ builder.Services.AddSwaggerGen(option => #endregion #region CORS sin cambios -// builder.Services.AddCors(p => p.AddPolicy("CORS", builder => -// { -// builder -// .AllowAnyOrigin() -// .AllowAnyMethod() -// .AllowAnyHeader(); -// })); builder.Services.AddCors(options => { - options.AddPolicy("CORS", policy => { /* @@ -182,8 +160,8 @@ var app = builder.Build(); //if (app.Environment.IsDevelopment()) //{ -app.UseSwagger(); -app.UseSwaggerUI(); + app.UseSwagger(); + app.UseSwaggerUI(); //} app.UseCors("CORS"); @@ -246,20 +224,18 @@ static void RepositorysAndServices(WebApplicationBuilder builder) builder.Services.AddScoped(); builder.Services.AddScoped(); - //builder.Services.AddScoped(); builder.Services.AddScoped(); // Registrar el service de lookup builder.Services.AddScoped(); builder.Services.AddScoped(); - // 2) Repositorio de histórico de cotizaciones + // Repositorio de histórico de cotizaciones builder.Services.AddScoped(); - // 3) Dominio/servicio con HttpClient para BCRA + // Dominio/servicio con HttpClient para BCRA builder.Services.AddHttpClient(client => { - client.BaseAddress = new Uri("https://api.bcra.gob.ar/"); }); diff --git a/phronCare.UIBlazor/Pages/Sales/Patients.razor b/phronCare.UIBlazor/Pages/Sales/Patients.razor index c97e42f..565ba2b 100644 --- a/phronCare.UIBlazor/Pages/Sales/Patients.razor +++ b/phronCare.UIBlazor/Pages/Sales/Patients.razor @@ -1,5 +1,5 @@ @page "/sales/patients" -@using phronCare.UIBlazor.Services.Sales +@using Services.Sales @using Domain.Entities @using Domain.Generics @using Domain.SearchParams diff --git a/phronCare.UIBlazor/Pages/Sales/Quotes/QuoteCreate.razor b/phronCare.UIBlazor/Pages/Sales/Quotes/QuoteCreate.razor index 1c18536..5ec29e4 100644 --- a/phronCare.UIBlazor/Pages/Sales/Quotes/QuoteCreate.razor +++ b/phronCare.UIBlazor/Pages/Sales/Quotes/QuoteCreate.razor @@ -2,19 +2,19 @@ @using System.Globalization; @using System.Net.Http.Json @using Blazored.Typeahead +@using Pages.Sales.Modals @using Services.Lookups -@using phronCare.UIBlazor.Pages.Sales.Modals -@using phronCare.UIBlazor.Services.Integrations -@using phronCare.UIBlazor.Services.Sales.Quotes +@using Services.Integrations +@using Services.Sales.Quotes @using Blazored.Toast.Services @using Blazored.Toast.Configuration -@inject ISalesLookupService SalesLookupService -@inject IQuoteService QuoteService -@inject IToastService toastService @inject NavigationManager Navigation -@inject IModalService Modal +@inject ISalesLookupService SalesLookupService @inject IExchangeRateService ExchangeRateService +@inject IQuoteService QuoteService +@inject IToastService toastService +@inject IModalService Modal
@@ -147,7 +147,6 @@
-
@@ -199,7 +198,6 @@ - } } @@ -212,9 +210,8 @@
- -
+
@@ -304,7 +299,6 @@
-