Implemented an API to retrieve a list of organizations provided in the contacts.
This commit is contained in:
parent
fbfd04c898
commit
635654890e
@ -113,6 +113,13 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("organization")]
|
||||||
|
public async Task<IActionResult> GetOrganizationList()
|
||||||
|
{
|
||||||
|
var response = await _directoryHelper.GetOrganizationList();
|
||||||
|
return Ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------- Contact Notes --------------------------------
|
// -------------------------------- Contact Notes --------------------------------
|
||||||
|
|
||||||
[HttpPost("note")]
|
[HttpPost("note")]
|
||||||
|
@ -743,6 +743,15 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
_logger.LogInfo("Employee ID {EmployeeId} sent an empty contact id", LoggedInEmployee.Id);
|
_logger.LogInfo("Employee ID {EmployeeId} sent an empty contact id", LoggedInEmployee.Id);
|
||||||
return ApiResponse<object>.ErrorResponse("Contact ID is empty", "Contact ID is empty", 400);
|
return ApiResponse<object>.ErrorResponse("Contact ID is empty", "Contact ID is empty", 400);
|
||||||
}
|
}
|
||||||
|
public async Task<ApiResponse<object>> GetOrganizationList()
|
||||||
|
{
|
||||||
|
Guid tenantId = _userHelper.GetTenantId();
|
||||||
|
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||||
|
|
||||||
|
var organizationList = await _context.Contacts.Where(c => c.TenantId == tenantId).Select(c => c.Organization).Distinct().ToListAsync();
|
||||||
|
_logger.LogInfo("Employee {EmployeeId} fetched list of organizations in a tenant {TenantId}", LoggedInEmployee.Id, tenantId);
|
||||||
|
return ApiResponse<object>.SuccessResponse(organizationList, $"{organizationList.Count} records of organization names fetched from contacts", 200);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------- Contact Notes --------------------------------
|
// -------------------------------- Contact Notes --------------------------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user