Sending number of conacts within the bucket with it information in API Update bucket, Assign Bucket, and Get Bucket List

This commit is contained in:
ashutosh.nehete 2025-05-28 11:36:40 +05:30
parent b42b8b726a
commit ad34ca12e6
2 changed files with 9 additions and 3 deletions

View File

@ -6,5 +6,6 @@
public string? Name { get; set; }
public string? Description { get; set; }
public List<Guid>? EmployeeIds { get; set; }
public int NumberOfContacts { get; set; }
}
}

View File

@ -1034,14 +1034,16 @@ namespace Marco.Pms.Services.Helpers
List<AssignBucketVM> bucketVMs = new List<AssignBucketVM>();
if (bucketList.Any())
{
bucketIds = bucketList.Select(b => b.Id).ToList();
List<ContactBucketMapping>? contactBucketMappings = await _context.ContactBucketMappings.Where(cb => bucketIds.Contains(cb.BucketId)).ToListAsync();
foreach (var bucket in bucketList)
{
List<EmployeeBucketMapping> employeeBucketMappings = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).ToList();
var emplyeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
List<ContactBucketMapping>? contactBuckets = contactBucketMappings.Where(cb => cb.BucketId == bucket.Id).ToList();
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
bucketVM.EmployeeIds = emplyeeIds;
bucketVM.NumberOfContacts = contactBuckets.Count;
bucketVMs.Add(bucketVM);
}
}
@ -1150,8 +1152,10 @@ namespace Marco.Pms.Services.Helpers
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
List<EmployeeBucketMapping> employeeBucketMappings = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).ToList();
List<ContactBucketMapping> contactBuckets = await _context.ContactBucketMappings.Where(eb => eb.BucketId == bucket.Id).ToListAsync();
var employeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
bucketVM.EmployeeIds = employeeIds;
bucketVM.NumberOfContacts = contactBuckets.Count;
_logger.LogInfo("Employee Id {LoggedInEmployeeId} Updated new bucket {BucketId}", LoggedInEmployee.Id, bucket.Id);
return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket update successFully", 200);
@ -1239,9 +1243,10 @@ namespace Marco.Pms.Services.Helpers
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
List<EmployeeBucketMapping> employeeBucketMappings = await _context.EmployeeBucketMappings.Where(eb => eb.BucketId == bucket.Id).ToListAsync();
List<ContactBucketMapping> contactBuckets = await _context.ContactBucketMappings.Where(eb => eb.BucketId == bucket.Id).ToListAsync();
employeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
bucketVM.EmployeeIds = employeeIds;
bucketVM.NumberOfContacts = contactBuckets.Count;
if (assignedEmployee > 0)
{