Firebase_Implementation #135

Merged
ashutosh.nehete merged 62 commits from Firebase_Implementation into main 2025-09-20 12:11:54 +00:00
2 changed files with 32 additions and 8 deletions
Showing only changes of commit a10b24523e - Show all commits

View File

@ -956,6 +956,10 @@ namespace Marco.Pms.Services.Service
try try
{ {
var contact = _mapper.Map<Contact>(createContact); var contact = _mapper.Map<Contact>(createContact);
if (string.IsNullOrWhiteSpace(createContact.Name))
{
contact.Description = string.Empty;
}
contact.CreatedAt = DateTime.UtcNow; contact.CreatedAt = DateTime.UtcNow;
contact.CreatedById = loggedInEmployeeId; contact.CreatedById = loggedInEmployeeId;
contact.TenantId = tenantId; contact.TenantId = tenantId;
@ -1117,6 +1121,14 @@ namespace Marco.Pms.Services.Service
// Update the main contact object from DTO // Update the main contact object from DTO
var updatedContact = _mapper.Map<Contact>(updateContact); var updatedContact = _mapper.Map<Contact>(updateContact);
if (string.IsNullOrWhiteSpace(updateContact.Designation))
{
updatedContact.Designation = string.Empty;
}
if (string.IsNullOrWhiteSpace(updateContact.Description))
{
updatedContact.Description = string.Empty;
}
updatedContact.TenantId = tenantId; updatedContact.TenantId = tenantId;
updatedContact.CreatedAt = contact.CreatedAt; updatedContact.CreatedAt = contact.CreatedAt;
updatedContact.CreatedById = contact.CreatedById; updatedContact.CreatedById = contact.CreatedById;
@ -3047,14 +3059,25 @@ namespace Marco.Pms.Services.Service
private async Task<(bool hasAdmin, bool hasManager, bool hasUser)> CheckPermissionsAsync(Guid employeeId) private async Task<(bool hasAdmin, bool hasManager, bool hasUser)> CheckPermissionsAsync(Guid employeeId)
{ {
// Scoping the service provider ensures services are disposed of correctly.
using var scope = _serviceScopeFactory.CreateScope();
var permissionService = scope.ServiceProvider.GetRequiredService<PermissionServices>();
// Run all permission checks in parallel. // Run all permission checks in parallel.
var hasAdminTask = permissionService.HasPermission(PermissionsMaster.DirectoryAdmin, employeeId); var hasAdminTask = Task.Run(async () =>
var hasManagerTask = permissionService.HasPermission(PermissionsMaster.DirectoryManager, employeeId); {
var hasUserTask = permissionService.HasPermission(PermissionsMaster.DirectoryUser, employeeId); using var scope = _serviceScopeFactory.CreateScope();
var permissionService = scope.ServiceProvider.GetRequiredService<PermissionServices>();
return await permissionService.HasPermission(PermissionsMaster.DirectoryAdmin, employeeId);
});
var hasManagerTask = Task.Run(async () =>
{
using var scope = _serviceScopeFactory.CreateScope();
var permissionService = scope.ServiceProvider.GetRequiredService<PermissionServices>();
return await permissionService.HasPermission(PermissionsMaster.DirectoryManager, employeeId);
});
var hasUserTask = Task.Run(async () =>
{
using var scope = _serviceScopeFactory.CreateScope();
var permissionService = scope.ServiceProvider.GetRequiredService<PermissionServices>();
return await permissionService.HasPermission(PermissionsMaster.DirectoryUser, employeeId);
});
await Task.WhenAll(hasAdminTask, hasManagerTask, hasUserTask); await Task.WhenAll(hasAdminTask, hasManagerTask, hasUserTask);

View File

@ -1761,7 +1761,8 @@ namespace Marco.Pms.Services.Service
var data = new Dictionary<string, string>() var data = new Dictionary<string, string>()
{ {
{ "Keyword", "Bucket_Modified" } { "Keyword", "Bucket_Modified" },
{"BucketId", bucketId.ToString() }
}; };
var registrationTokensForNotification = await _context.FCMTokenMappings.Where(ft => assignedEmployeeIds.Contains(ft.EmployeeId) && ft.ExpiredAt >= DateTime.UtcNow).Select(ft => ft.FcmToken).ToListAsync(); var registrationTokensForNotification = await _context.FCMTokenMappings.Where(ft => assignedEmployeeIds.Contains(ft.EmployeeId) && ft.ExpiredAt >= DateTime.UtcNow).Select(ft => ft.FcmToken).ToListAsync();