diff --git a/Marco.Pms.Services/Controllers/OrganizationController.cs b/Marco.Pms.Services/Controllers/OrganizationController.cs index b31bfb1..b2b6c4a 100644 --- a/Marco.Pms.Services/Controllers/OrganizationController.cs +++ b/Marco.Pms.Services/Controllers/OrganizationController.cs @@ -46,10 +46,10 @@ namespace Marco.Pms.Services.Controllers } [HttpGet("list/basic")] - public async Task GetOrganizationBasicList([FromQuery] string? searchString, CancellationToken ct, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 20) + public async Task GetOrganizationBasicList([FromQuery] Guid? id, [FromQuery] string? searchString, CancellationToken ct, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 20) { var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync(); - var response = await _organizationService.GetOrganizationBasicListAsync(searchString, pageNumber, pageSize, loggedInEmployee, ct); + var response = await _organizationService.GetOrganizationBasicListAsync(id, searchString, pageNumber, pageSize, loggedInEmployee, ct); return StatusCode(response.StatusCode, response); } diff --git a/Marco.Pms.Services/Controllers/ProjectController.cs b/Marco.Pms.Services/Controllers/ProjectController.cs index 9b49119..cdc2b61 100644 --- a/Marco.Pms.Services/Controllers/ProjectController.cs +++ b/Marco.Pms.Services/Controllers/ProjectController.cs @@ -41,11 +41,11 @@ namespace MarcoBMS.Services.Controllers #region =================================================================== Project Get APIs =================================================================== [HttpGet("list/basic/all")] - public async Task GetBothProjectBasicList([FromQuery] string? searchString) + public async Task GetBothProjectBasicList([FromQuery] Guid? id, [FromQuery] string? searchString) { // Get the current user var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync(); - var response = await _projectServices.GetBothProjectBasicListAsync(searchString, loggedInEmployee, tenantId); + var response = await _projectServices.GetBothProjectBasicListAsync(id, searchString, loggedInEmployee, tenantId); return StatusCode(response.StatusCode, response); } diff --git a/Marco.Pms.Services/Service/OrganizationService.cs b/Marco.Pms.Services/Service/OrganizationService.cs index 7bfab16..e116a4a 100644 --- a/Marco.Pms.Services/Service/OrganizationService.cs +++ b/Marco.Pms.Services/Service/OrganizationService.cs @@ -163,7 +163,7 @@ namespace Marco.Pms.Services.Service /// The current user context for security filtering. /// Cancellation token to cancel operations if the client disconnects. /// A paginated list of BasicOrganizationVm. - public async Task> GetOrganizationBasicListAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct = default) + public async Task> GetOrganizationBasicListAsync(Guid? id, string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct = default) { try { @@ -188,6 +188,11 @@ namespace Marco.Pms.Services.Service query = query.Where(o => o.Name.Contains(searchTrimmed)); } + if (id.HasValue) + { + query = query.Where(o => o.Id == id.Value); + } + // 5. COUNT TOTALS (Efficiently) // Count the total records matching the filter BEFORE applying pagination var totalCount = await query.CountAsync(ct); diff --git a/Marco.Pms.Services/Service/ProjectServices.cs b/Marco.Pms.Services/Service/ProjectServices.cs index 9be8957..e9cb9d7 100644 --- a/Marco.Pms.Services/Service/ProjectServices.cs +++ b/Marco.Pms.Services/Service/ProjectServices.cs @@ -61,7 +61,7 @@ namespace Marco.Pms.Services.Service /// Authenticated employee requesting the data. /// Tenant identifier to ensure multi-tenant data isolation. /// Returns an ApiResponse containing the distinct combined list of basic project view models or an error response. - public async Task> GetBothProjectBasicListAsync(string? searchString, Employee loggedInEmployee, Guid tenantId) + public async Task> GetBothProjectBasicListAsync(Guid? id, string? searchString, Employee loggedInEmployee, Guid tenantId) { if (tenantId == Guid.Empty) { @@ -88,6 +88,10 @@ namespace Marco.Pms.Services.Service .Where(p => p.Name.ToLower().Contains(normalized) || (!string.IsNullOrWhiteSpace(p.ShortName) && p.ShortName.ToLower().Contains(normalized))); } + if (id.HasValue) + { + infraProjectsQuery = infraProjectsQuery.Where(p => p.Id == id.Value); + } var infraProjects = await infraProjectsQuery.ToListAsync(); return infraProjects.Select(p => _mapper.Map(p)).ToList(); @@ -108,6 +112,11 @@ namespace Marco.Pms.Services.Service (!string.IsNullOrWhiteSpace(sp.ShortName) && sp.ShortName.ToLower().Contains(normalized))); } + if (id.HasValue) + { + serviceProjectsQuery = serviceProjectsQuery.Where(sp => sp.Id == id.Value); + } + var serviceProjects = await serviceProjectsQuery.ToListAsync(); return serviceProjects.Select(sp => _mapper.Map(sp)).ToList(); }); diff --git a/Marco.Pms.Services/Service/ServiceInterfaces/IOrganizationService.cs b/Marco.Pms.Services/Service/ServiceInterfaces/IOrganizationService.cs index 6abbe83..36f0208 100644 --- a/Marco.Pms.Services/Service/ServiceInterfaces/IOrganizationService.cs +++ b/Marco.Pms.Services/Service/ServiceInterfaces/IOrganizationService.cs @@ -8,7 +8,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces { #region =================================================================== Get Functions =================================================================== Task> GetOrganizarionListAsync(string? searchString, long? sprid, bool active, int pageNumber, int pageSize, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId); - Task> GetOrganizationBasicListAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct); + Task> GetOrganizationBasicListAsync(Guid? id, string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct); Task> GetOrganizationDetailsAsync(Guid id, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId); Task> GetOrganizationHierarchyListAsync(Guid employeeId, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId); #endregion diff --git a/Marco.Pms.Services/Service/ServiceInterfaces/IProjectServices.cs b/Marco.Pms.Services/Service/ServiceInterfaces/IProjectServices.cs index 98b36d6..2042987 100644 --- a/Marco.Pms.Services/Service/ServiceInterfaces/IProjectServices.cs +++ b/Marco.Pms.Services/Service/ServiceInterfaces/IProjectServices.cs @@ -10,7 +10,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces { public interface IProjectServices { - Task> GetBothProjectBasicListAsync(string? searchString, Employee loggedInEmployee, Guid tenantId); + Task> GetBothProjectBasicListAsync(Guid? id, string? searchString, Employee loggedInEmployee, Guid tenantId); Task> GetAllProjectsBasicAsync(bool provideAll, Employee loggedInEmployee, Guid tenantId); Task> GetAllProjectsAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, Guid tenantId); Task> GetProjectAsync(Guid id, Employee loggedInEmployee, Guid tenantId);