Searching project through short name as well

This commit is contained in:
ashutosh.nehete 2025-11-19 10:52:16 +05:30
parent a7a9fb4012
commit eed97d31c6

View File

@ -52,7 +52,8 @@ namespace Marco.Pms.Services.Service
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
} }
#region =================================================================== Project Get APIs =================================================================== #region =================================================================== Project Get APIs ===================================================================\
/// <summary> /// <summary>
/// Retrieves a combined list of basic infrastructure and active service projects accessible by the logged-in employee within a tenant. /// Retrieves a combined list of basic infrastructure and active service projects accessible by the logged-in employee within a tenant.
/// </summary> /// </summary>
@ -84,7 +85,8 @@ namespace Marco.Pms.Services.Service
{ {
var normalized = searchString.Trim().ToLowerInvariant(); var normalized = searchString.Trim().ToLowerInvariant();
infraProjectsQuery = infraProjectsQuery infraProjectsQuery = infraProjectsQuery
.Where(p => p.Name.ToLower().Contains(normalized)); .Where(p => p.Name.ToLower().Contains(normalized) ||
(!string.IsNullOrWhiteSpace(p.ShortName) && p.ShortName.ToLower().Contains(normalized)));
} }
var infraProjects = await infraProjectsQuery.ToListAsync(); var infraProjects = await infraProjectsQuery.ToListAsync();
@ -102,7 +104,8 @@ namespace Marco.Pms.Services.Service
{ {
var normalized = searchString.Trim().ToLowerInvariant(); var normalized = searchString.Trim().ToLowerInvariant();
serviceProjectsQuery = serviceProjectsQuery serviceProjectsQuery = serviceProjectsQuery
.Where(sp => sp.Name.ToLower().Contains(normalized)); .Where(sp => sp.Name.ToLower().Contains(normalized) ||
(!string.IsNullOrWhiteSpace(sp.ShortName) && sp.ShortName.ToLower().Contains(normalized)));
} }
var serviceProjects = await serviceProjectsQuery.ToListAsync(); var serviceProjects = await serviceProjectsQuery.ToListAsync();
@ -127,7 +130,6 @@ namespace Marco.Pms.Services.Service
return ApiResponse<object>.ErrorResponse("Internal Server Error", "An error occurred while fetching projects.", 500); return ApiResponse<object>.ErrorResponse("Internal Server Error", "An error occurred while fetching projects.", 500);
} }
} }
public async Task<ApiResponse<object>> GetAllProjectsBasicAsync(bool provideAll, Employee loggedInEmployee, Guid tenantId) public async Task<ApiResponse<object>> GetAllProjectsBasicAsync(bool provideAll, Employee loggedInEmployee, Guid tenantId)
{ {
try try