ref: project structure

This commit is contained in:
2026-08-19 23:25:08 +07:00
parent 05a93cfc09
commit a1fe31cf70
155 changed files with 3339 additions and 1007 deletions
@@ -0,0 +1,35 @@
using AutoMapper;
using MediatR;
using mws.backend.dotnet.application.Common;
using mws.backend.dotnet.domain.Documents;
namespace mws.backend.dotnet.application.Projects;
public record GetProjectOverviewQuery(Guid UserId, Guid ProjectId) : IRequest<ProjectOverviewDto>;
public class GetProjectOverviewHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<GetProjectOverviewQuery, ProjectOverviewDto>
{
public async Task<ProjectOverviewDto> Handle(GetProjectOverviewQuery query, CancellationToken ct)
{
var project = await ProjectAccess.GetForUserOrThrowAsync(uow, query.UserId, query.ProjectId, ct);
var memberCount = await uow.Projects.CountMembersAsync(query.ProjectId, ct);
var documentCount = await uow.Documents.CountByTypeForProjectAsync(query.ProjectId, DocumentType.Document, ct);
var taskCounts = await uow.Tasks.CountByStatusForProjectAsync(query.ProjectId, ct);
var taskCountsByStatus = taskCounts.ToDictionary(kv => kv.Key.ToString(), kv => kv.Value);
var recentTasks = await uow.Tasks.GetRecentForProjectAsync(query.ProjectId, 5, ct);
var recentDocuments = await uow.Documents.GetRecentForProjectAsync(query.ProjectId, DocumentType.Document, 5, ct);
return new ProjectOverviewDto
{
Project = mapper.Map<ProjectDto>(project),
MemberCount = memberCount,
DocumentCount = documentCount,
TaskCountsByStatus = taskCountsByStatus,
RecentTasks = mapper.Map<List<RecentTaskDto>>(recentTasks),
RecentDocuments = mapper.Map<List<RecentDocumentDto>>(recentDocuments),
};
}
}