Add Patch in CustomerController
Some checks failed
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Failing after 43s

This commit is contained in:
Leandro Hernan Rojas 2025-04-05 19:24:02 -03:00
parent f61f26c98b
commit 143c3b45e7
2 changed files with 11 additions and 9 deletions

View File

@ -42,7 +42,7 @@ namespace Models.Repositories
.Include(c => c.Accounttypes)
.Include(c => c.PhSCustomerDocuments)
.Include(c => c.PhSCustomerAddresses)
.Take(3)
.Take(100)
.AsQueryable();
if (!string.IsNullOrWhiteSpace(name))
@ -53,12 +53,6 @@ namespace Models.Repositories
c.BusinessName.ToLower().Contains(loweredName));
}
if (!string.IsNullOrWhiteSpace(document) && document != "?")
{
query = query.Where(c =>
c.PhSCustomerDocuments.Any(a =>
EF.Functions.Like(a.DocumentNumber, $"%{document}%")));
}
if (!string.IsNullOrWhiteSpace(email))
{
var loweredEmail = email.ToLower();
@ -67,6 +61,13 @@ namespace Models.Repositories
a.Email.ToLower().Contains(loweredEmail)));
}
if (!string.IsNullOrWhiteSpace(document) && document != "?")
{
query = query.Where(c =>
c.PhSCustomerDocuments.Any(a =>
EF.Functions.Like(a.DocumentNumber, $"%{document}%")));
}
var customers = await query.ToListAsync();
Console.WriteLine($"VALOR RECIBIDO DE 'name': {name}");

View File

@ -28,11 +28,12 @@ namespace phronCare.API.Controllers.Sales
}
}
[HttpGet("search")]
public async Task<IActionResult> Search([FromQuery] string? name, [FromQuery] string? email, [FromQuery] string? document)
public async Task<IActionResult> Search([FromQuery] string? name, [FromQuery] string? document, [FromQuery] string? email)
{
try
{
var result = await _customerService.SearchAsync(name, email, document);
var result = await _customerService.SearchAsync(name, document,);
var result = await _customerService.SearchAsync(name, document,);
return Ok(result);
}
catch (Exception ex)