From 5387e009cbd373aad12fd2e1c068d3805406babe Mon Sep 17 00:00:00 2001 From: "ashutosh.nehete" Date: Tue, 9 Dec 2025 19:13:08 +0530 Subject: [PATCH] sorted the service , activity group and activity by names --- .../Controllers/MasterController.cs | 4 ++-- Marco.Pms.Services/Service/MasterService.cs | 17 ++++++++++++----- .../Service/ServiceInterfaces/IMasterService.cs | 4 +++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Marco.Pms.Services/Controllers/MasterController.cs b/Marco.Pms.Services/Controllers/MasterController.cs index 4a7b142..0169651 100644 --- a/Marco.Pms.Services/Controllers/MasterController.cs +++ b/Marco.Pms.Services/Controllers/MasterController.cs @@ -257,10 +257,10 @@ namespace Marco.Pms.Services.Controllers [HttpGet] [Route("activities")] - public async Task GetActivitiesMaster([FromQuery] Guid? activityGroupId) + public async Task GetActivitiesMaster([FromQuery] Guid? activityGroupId, [FromQuery] string? searchString) { var loggedInEmployee = await _userHelper.GetCurrentEmployeeAsync(); - var response = await _masterService.GetActivitiesMasterAsync(activityGroupId, loggedInEmployee, tenantId); + var response = await _masterService.GetActivitiesMasterAsync(activityGroupId, searchString, loggedInEmployee, tenantId); return StatusCode(response.StatusCode, response); } diff --git a/Marco.Pms.Services/Service/MasterService.cs b/Marco.Pms.Services/Service/MasterService.cs index baac924..763c282 100644 --- a/Marco.Pms.Services/Service/MasterService.cs +++ b/Marco.Pms.Services/Service/MasterService.cs @@ -521,6 +521,7 @@ namespace Marco.Pms.Services.Service var services = await _context.ServiceMasters .Where(s => s.TenantId == tenantId && s.IsActive) .Select(s => _mapper.Map(s)) + .OrderBy(s => s.Name) .ToListAsync(); _logger.LogInfo("Fetched {Count} service records for tenantId: {TenantId}", services.Count, tenantId); @@ -628,11 +629,11 @@ namespace Marco.Pms.Services.Service IsSystem = a.IsSystem, CheckLists = _mapper.Map>(checklistForActivity) }; - }).ToList() - }).ToList() + }).OrderBy(a => a.ActivityName).ToList() + }).OrderBy(ag => ag.Name).ToList() }; return response; - }).ToList(); + }).OrderBy(s => s.Name).ToList(); _logger.LogInfo("Successfully processed and mapped {ServiceCount} services for TenantId: {TenantId}", Vm.Count, tenantId); @@ -836,6 +837,7 @@ namespace Marco.Pms.Services.Service var activityGroups = await activityGroupQuery .Select(ag => _mapper.Map(ag)) + .OrderBy(ag => ag.Name) .ToListAsync(); _logger.LogInfo("{Count} activity group(s) fetched for tenantId: {TenantId}", activityGroups.Count, tenantId); @@ -1032,7 +1034,7 @@ namespace Marco.Pms.Services.Service #endregion #region =================================================================== Activity APIs =================================================================== - public async Task> GetActivitiesMasterAsync(Guid? activityGroupId, Employee loggedInEmployee, Guid tenantId) + public async Task> GetActivitiesMasterAsync(Guid? activityGroupId, string? searchString, Employee loggedInEmployee, Guid tenantId) { _logger.LogInfo("GetActivitiesMaster called"); @@ -1050,6 +1052,11 @@ namespace Marco.Pms.Services.Service activityQuery = activityQuery.Where(a => a.ActivityGroupId == activityGroupId); } + if (!string.IsNullOrWhiteSpace(searchString)) + { + activityQuery = activityQuery.Where(a => a.ActivityName.Contains(searchString)); + } + var activities = await activityQuery .ToListAsync(); @@ -1081,7 +1088,7 @@ namespace Marco.Pms.Services.Service response.CheckLists = _mapper.Map>(checklistForActivity); return response; - }).ToList(); + }).OrderBy(a => a.ActivityName).ToList(); _logger.LogInfo("{Count} activity records fetched successfully for tenantId: {TenantId}", activityVMs.Count, tenantId); diff --git a/Marco.Pms.Services/Service/ServiceInterfaces/IMasterService.cs b/Marco.Pms.Services/Service/ServiceInterfaces/IMasterService.cs index 889c8fb..30e4b9e 100644 --- a/Marco.Pms.Services/Service/ServiceInterfaces/IMasterService.cs +++ b/Marco.Pms.Services/Service/ServiceInterfaces/IMasterService.cs @@ -26,10 +26,12 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces Task> GetPurchaseInvoiceStatusAsync(Employee loggedInEmployee, CancellationToken cancellationToken); #endregion + #region =================================================================== Invoice Attachment Type APIs =================================================================== Task> GetInvoiceAttachmentTypeAsync(Employee loggedInEmployee, CancellationToken cancellationToken); #endregion + #region =================================================================== Currency APIs =================================================================== Task> GetCurrencyAsync(Employee loggedInEmployee, Guid tenantId); @@ -58,7 +60,7 @@ namespace Marco.Pms.Services.Service.ServiceInterfaces #endregion #region =================================================================== Activity APIs =================================================================== - Task> GetActivitiesMasterAsync(Guid? activityGroupId, Employee loggedInEmployee, Guid tenantId); + Task> GetActivitiesMasterAsync(Guid? activityGroupId, string? searchString, Employee loggedInEmployee, Guid tenantId); Task> CreateActivityAsync(CreateActivityMasterDto createActivity, Employee loggedInEmployee, Guid tenantId); Task> UpdateActivityAsync(Guid id, CreateActivityMasterDto createActivity, Employee loggedInEmployee, Guid tenantId); Task> DeleteActivityAsync(Guid id, bool isActive, Employee loggedInEmployee, Guid tenantId);