Added filter by id as well in both project list API and basic Organization list API
This commit is contained in:
parent
0fe59223e2
commit
49da601092
@ -46,10 +46,10 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("list/basic")]
|
[HttpGet("list/basic")]
|
||||||
public async Task<IActionResult> GetOrganizationBasicList([FromQuery] string? searchString, CancellationToken ct, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 20)
|
public async Task<IActionResult> GetOrganizationBasicList([FromQuery] Guid? id, [FromQuery] string? searchString, CancellationToken ct, [FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 20)
|
||||||
{
|
{
|
||||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
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);
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,11 +41,11 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
#region =================================================================== Project Get APIs ===================================================================
|
#region =================================================================== Project Get APIs ===================================================================
|
||||||
|
|
||||||
[HttpGet("list/basic/all")]
|
[HttpGet("list/basic/all")]
|
||||||
public async Task<IActionResult> GetBothProjectBasicList([FromQuery] string? searchString)
|
public async Task<IActionResult> GetBothProjectBasicList([FromQuery] Guid? id, [FromQuery] string? searchString)
|
||||||
{
|
{
|
||||||
// Get the current user
|
// Get the current user
|
||||||
var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
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);
|
return StatusCode(response.StatusCode, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -163,7 +163,7 @@ namespace Marco.Pms.Services.Service
|
|||||||
/// <param name="loggedInEmployee">The current user context for security filtering.</param>
|
/// <param name="loggedInEmployee">The current user context for security filtering.</param>
|
||||||
/// <param name="ct">Cancellation token to cancel operations if the client disconnects.</param>
|
/// <param name="ct">Cancellation token to cancel operations if the client disconnects.</param>
|
||||||
/// <returns>A paginated list of BasicOrganizationVm.</returns>
|
/// <returns>A paginated list of BasicOrganizationVm.</returns>
|
||||||
public async Task<ApiResponse<object>> GetOrganizationBasicListAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct = default)
|
public async Task<ApiResponse<object>> GetOrganizationBasicListAsync(Guid? id, string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -188,6 +188,11 @@ namespace Marco.Pms.Services.Service
|
|||||||
query = query.Where(o => o.Name.Contains(searchTrimmed));
|
query = query.Where(o => o.Name.Contains(searchTrimmed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id.HasValue)
|
||||||
|
{
|
||||||
|
query = query.Where(o => o.Id == id.Value);
|
||||||
|
}
|
||||||
|
|
||||||
// 5. COUNT TOTALS (Efficiently)
|
// 5. COUNT TOTALS (Efficiently)
|
||||||
// Count the total records matching the filter BEFORE applying pagination
|
// Count the total records matching the filter BEFORE applying pagination
|
||||||
var totalCount = await query.CountAsync(ct);
|
var totalCount = await query.CountAsync(ct);
|
||||||
|
|||||||
@ -61,7 +61,7 @@ namespace Marco.Pms.Services.Service
|
|||||||
/// <param name="loggedInEmployee">Authenticated employee requesting the data.</param>
|
/// <param name="loggedInEmployee">Authenticated employee requesting the data.</param>
|
||||||
/// <param name="tenantId">Tenant identifier to ensure multi-tenant data isolation.</param>
|
/// <param name="tenantId">Tenant identifier to ensure multi-tenant data isolation.</param>
|
||||||
/// <returns>Returns an ApiResponse containing the distinct combined list of basic project view models or an error response.</returns>
|
/// <returns>Returns an ApiResponse containing the distinct combined list of basic project view models or an error response.</returns>
|
||||||
public async Task<ApiResponse<object>> GetBothProjectBasicListAsync(string? searchString, Employee loggedInEmployee, Guid tenantId)
|
public async Task<ApiResponse<object>> GetBothProjectBasicListAsync(Guid? id, string? searchString, Employee loggedInEmployee, Guid tenantId)
|
||||||
{
|
{
|
||||||
if (tenantId == Guid.Empty)
|
if (tenantId == Guid.Empty)
|
||||||
{
|
{
|
||||||
@ -88,6 +88,10 @@ namespace Marco.Pms.Services.Service
|
|||||||
.Where(p => p.Name.ToLower().Contains(normalized) ||
|
.Where(p => p.Name.ToLower().Contains(normalized) ||
|
||||||
(!string.IsNullOrWhiteSpace(p.ShortName) && p.ShortName.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();
|
var infraProjects = await infraProjectsQuery.ToListAsync();
|
||||||
return infraProjects.Select(p => _mapper.Map<BasicProjectVM>(p)).ToList();
|
return infraProjects.Select(p => _mapper.Map<BasicProjectVM>(p)).ToList();
|
||||||
@ -108,6 +112,11 @@ namespace Marco.Pms.Services.Service
|
|||||||
(!string.IsNullOrWhiteSpace(sp.ShortName) && sp.ShortName.ToLower().Contains(normalized)));
|
(!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();
|
var serviceProjects = await serviceProjectsQuery.ToListAsync();
|
||||||
return serviceProjects.Select(sp => _mapper.Map<BasicProjectVM>(sp)).ToList();
|
return serviceProjects.Select(sp => _mapper.Map<BasicProjectVM>(sp)).ToList();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces
|
|||||||
{
|
{
|
||||||
#region =================================================================== Get Functions ===================================================================
|
#region =================================================================== Get Functions ===================================================================
|
||||||
Task<ApiResponse<object>> GetOrganizarionListAsync(string? searchString, long? sprid, bool active, int pageNumber, int pageSize, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId);
|
Task<ApiResponse<object>> GetOrganizarionListAsync(string? searchString, long? sprid, bool active, int pageNumber, int pageSize, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId);
|
||||||
Task<ApiResponse<object>> GetOrganizationBasicListAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct);
|
Task<ApiResponse<object>> GetOrganizationBasicListAsync(Guid? id, string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, CancellationToken ct);
|
||||||
Task<ApiResponse<object>> GetOrganizationDetailsAsync(Guid id, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId);
|
Task<ApiResponse<object>> GetOrganizationDetailsAsync(Guid id, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId);
|
||||||
Task<ApiResponse<object>> GetOrganizationHierarchyListAsync(Guid employeeId, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId);
|
Task<ApiResponse<object>> GetOrganizationHierarchyListAsync(Guid employeeId, Employee loggedInEmployee, Guid tenantId, Guid loggedOrganizationId);
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces
|
|||||||
{
|
{
|
||||||
public interface IProjectServices
|
public interface IProjectServices
|
||||||
{
|
{
|
||||||
Task<ApiResponse<object>> GetBothProjectBasicListAsync(string? searchString, Employee loggedInEmployee, Guid tenantId);
|
Task<ApiResponse<object>> GetBothProjectBasicListAsync(Guid? id, string? searchString, Employee loggedInEmployee, Guid tenantId);
|
||||||
Task<ApiResponse<object>> GetAllProjectsBasicAsync(bool provideAll, Employee loggedInEmployee, Guid tenantId);
|
Task<ApiResponse<object>> GetAllProjectsBasicAsync(bool provideAll, Employee loggedInEmployee, Guid tenantId);
|
||||||
Task<ApiResponse<object>> GetAllProjectsAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, Guid tenantId);
|
Task<ApiResponse<object>> GetAllProjectsAsync(string? searchString, int pageNumber, int pageSize, Employee loggedInEmployee, Guid tenantId);
|
||||||
Task<ApiResponse<object>> GetProjectAsync(Guid id, Employee loggedInEmployee, Guid tenantId);
|
Task<ApiResponse<object>> GetProjectAsync(Guid id, Employee loggedInEmployee, Guid tenantId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user