Created an endpoint to fetch list of all contact category in that tenant

This commit is contained in:
ashutosh.nehete 2025-05-15 14:59:30 +05:30
parent 84cfdc29b2
commit c2223e4029
2 changed files with 19 additions and 2 deletions

View File

@ -676,7 +676,8 @@ namespace Marco.Pms.Services.Controllers
[HttpGet("contact-categories")] [HttpGet("contact-categories")]
public async Task<IActionResult> GetContactCategoryMasterList() public async Task<IActionResult> GetContactCategoryMasterList()
{ {
return Ok(); var response = await _masterHelper.GetContactCategoriesList();
return Ok(response);
} }
[HttpGet("contact-category/{id})")] [HttpGet("contact-category/{id})")]
@ -715,7 +716,7 @@ namespace Marco.Pms.Services.Controllers
return Ok(); return Ok();
} }
// -------------------------------- Contact Category -------------------------------- // -------------------------------- Contact Tag --------------------------------
[HttpGet("contact-tags")] [HttpGet("contact-tags")]
public async Task<IActionResult> GetContactTagMasterList() public async Task<IActionResult> GetContactTagMasterList()

View File

@ -48,6 +48,22 @@ namespace Marco.Pms.Services.Helpers
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400); return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
} }
public async Task<ApiResponse<object>> GetContactCategoriesList()
{
Guid tenantId = _userHelper.GetTenantId();
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
var categoryList = await _context.ContactCategoryMasters.Where(c => c.TenantId == tenantId).ToListAsync();
List<ContactCategoryVM> contactCategories = new List<ContactCategoryVM>();
foreach (var category in categoryList)
{
ContactCategoryVM categoryVM = category.ToContactCategoryVMFromContactCategoryMaster();
contactCategories.Add(categoryVM);
}
_logger.LogInfo("{count} contact categoires are fetched by Employee with ID {LoggedInEmployeeId}", contactCategories.Count, LoggedInEmployee.Id);
return ApiResponse<object>.SuccessResponse(contactCategories, System.String.Format("{0} contact categories fetched successfully", contactCategories.Count), 200);
}
// -------------------------------- Contact Tag -------------------------------- // -------------------------------- Contact Tag --------------------------------
// -------------------------------- Bucket -------------------------------- // -------------------------------- Bucket --------------------------------
} }