Sending every project exists in expense table
This commit is contained in:
parent
1c9008ca62
commit
36db35d90e
@ -344,16 +344,12 @@ namespace Marco.Pms.Services.Service
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var scope = _serviceScopeFactory.CreateScope();
|
|
||||||
var projectHelper = scope.ServiceProvider.GetRequiredService<IProjectServices>();
|
|
||||||
var projectIds = await projectHelper.GetMyProjectIdsAsync(tenantId, loggedInEmployee);
|
|
||||||
|
|
||||||
// Task 1: Get all distinct projects associated with the tenant's expenses.
|
// Task 1: Get all distinct projects associated with the tenant's expenses.
|
||||||
var projectsTask = Task.Run(async () =>
|
var projectsTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await using var dbContext = await _dbContextFactory.CreateDbContextAsync();
|
await using var dbContext = await _dbContextFactory.CreateDbContextAsync();
|
||||||
return await dbContext.Expenses
|
return await dbContext.Expenses
|
||||||
.Where(e => e.TenantId == tenantId && e.Project != null && projectIds.Contains(e.ProjectId))
|
.Where(e => e.TenantId == tenantId && e.Project != null)
|
||||||
.Select(e => e.Project!)
|
.Select(e => e.Project!)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.Select(p => new { p.Id, Name = $"{p.Name}" })
|
.Select(p => new { p.Id, Name = $"{p.Name}" })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user