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:
parent
453a64fea0
commit
197b4aea8d
@ -6,5 +6,6 @@
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public List<Guid>? EmployeeIds { get; set; }
|
public List<Guid>? EmployeeIds { get; set; }
|
||||||
|
public int NumberOfContacts { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1054,14 +1054,16 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
List<AssignBucketVM> bucketVMs = new List<AssignBucketVM>();
|
List<AssignBucketVM> bucketVMs = new List<AssignBucketVM>();
|
||||||
if (bucketList.Any())
|
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)
|
foreach (var bucket in bucketList)
|
||||||
{
|
{
|
||||||
List<EmployeeBucketMapping> employeeBucketMappings = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).ToList();
|
List<EmployeeBucketMapping> employeeBucketMappings = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).ToList();
|
||||||
var emplyeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
|
var emplyeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
|
||||||
|
List<ContactBucketMapping>? contactBuckets = contactBucketMappings.Where(cb => cb.BucketId == bucket.Id).ToList();
|
||||||
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
|
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
|
||||||
bucketVM.EmployeeIds = emplyeeIds;
|
bucketVM.EmployeeIds = emplyeeIds;
|
||||||
|
bucketVM.NumberOfContacts = contactBuckets.Count;
|
||||||
bucketVMs.Add(bucketVM);
|
bucketVMs.Add(bucketVM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1170,8 +1172,10 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
|
|
||||||
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
|
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
|
||||||
List<EmployeeBucketMapping> employeeBucketMappings = employeeBuckets.Where(eb => eb.BucketId == bucket.Id).ToList();
|
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();
|
var employeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
|
||||||
bucketVM.EmployeeIds = employeeIds;
|
bucketVM.EmployeeIds = employeeIds;
|
||||||
|
bucketVM.NumberOfContacts = contactBuckets.Count;
|
||||||
|
|
||||||
_logger.LogInfo("Employee Id {LoggedInEmployeeId} Updated new bucket {BucketId}", LoggedInEmployee.Id, bucket.Id);
|
_logger.LogInfo("Employee Id {LoggedInEmployeeId} Updated new bucket {BucketId}", LoggedInEmployee.Id, bucket.Id);
|
||||||
return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket update successFully", 200);
|
return ApiResponse<object>.SuccessResponse(bucketVM, "Bucket update successFully", 200);
|
||||||
@ -1259,9 +1263,10 @@ namespace Marco.Pms.Services.Helpers
|
|||||||
|
|
||||||
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
|
AssignBucketVM bucketVM = bucket.ToAssignBucketVMFromBucket();
|
||||||
List<EmployeeBucketMapping> employeeBucketMappings = await _context.EmployeeBucketMappings.Where(eb => eb.BucketId == bucket.Id).ToListAsync();
|
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();
|
employeeIds = employeeBucketMappings.Select(eb => eb.EmployeeId).ToList();
|
||||||
bucketVM.EmployeeIds = employeeIds;
|
bucketVM.EmployeeIds = employeeIds;
|
||||||
|
bucketVM.NumberOfContacts = contactBuckets.Count;
|
||||||
|
|
||||||
if (assignedEmployee > 0)
|
if (assignedEmployee > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user