fix subAccount Workshop Personnel Count
This commit is contained in:
@@ -308,7 +308,7 @@ public class AccountApplication : IAccountApplication
|
||||
{
|
||||
Slug = _passwordHasher.SlugHasher(x.WorkshopId),
|
||||
Name = x.WorkshopName,
|
||||
PersonnelCount = 0,
|
||||
PersonnelCount = x.PersonnelCount,
|
||||
Id = x.WorkshopId
|
||||
}).ToList();
|
||||
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace CompanyManagment.App.Contracts.Workshop
|
||||
public string WorkshopName { get; set; }
|
||||
public long SubAccountId { get; set; }
|
||||
public string IsActive { get; set; }
|
||||
public int PersonnelCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using _0_Framework.InfraStructure;
|
||||
using System;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.WorkshopSubAccountAgg;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using AccountManagement.Domain.SubAccountAgg;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
@@ -17,15 +20,25 @@ public class WorkshopSubAccountRepository : RepositoryBase<long, WorkshopSubAcco
|
||||
|
||||
public List<WorkshopSubAccountViewModel> GetWorkshopsBySubAccountId(long subAccountId)
|
||||
{
|
||||
return _companyContext.WorkshopSubAccounts.Include(x => x.Workshop).Where(x => x.SubAccountId == subAccountId)
|
||||
.Select(x => new WorkshopSubAccountViewModel()
|
||||
var dateNow = DateTime.Today;
|
||||
|
||||
var viewModelList = _companyContext.WorkshopSubAccounts
|
||||
.Include(x => x.Workshop)
|
||||
.Where(x => x.SubAccountId == subAccountId)
|
||||
.Select(sub => new WorkshopSubAccountViewModel
|
||||
{
|
||||
SubAccountId = x.SubAccountId,
|
||||
IsActive = x.IsActive.ToString(),
|
||||
WorkshopId = x.WorkshopId,
|
||||
WorkshopName = x.Workshop.WorkshopName,
|
||||
SubAccountId = sub.SubAccountId,
|
||||
IsActive = sub.IsActive.ToString(),
|
||||
WorkshopId = sub.WorkshopId,
|
||||
WorkshopName = sub.Workshop.WorkshopName,
|
||||
PersonnelCount = _companyContext.LeftWorkList.Count(left =>
|
||||
left.WorkshopId == sub.WorkshopId &&
|
||||
left.StartWorkDate <= dateNow &&
|
||||
left.LeftWorkDate > dateNow)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return viewModelList;
|
||||
}
|
||||
|
||||
public List<WorkshopSubAccount> GetWorkshopsSubAccountEntityBySubAccountId(long subAccountId)
|
||||
|
||||
Reference in New Issue
Block a user