diff --git a/Company.Domain/SalaryAidAgg/ISalaryAidRepository.cs b/Company.Domain/SalaryAidAgg/ISalaryAidRepository.cs index 4acc1cec..c1a7cf87 100644 --- a/Company.Domain/SalaryAidAgg/ISalaryAidRepository.cs +++ b/Company.Domain/SalaryAidAgg/ISalaryAidRepository.cs @@ -15,12 +15,11 @@ public interface ISalaryAidRepository:IRepository void RemoveRange(IEnumerable salaryAids); #region Pooya - /// /// گروهبندی بر اساس ماه هنگام جستجو با انتخاب کارمند /// - SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel); + SalaryAidsGroupedViewModel GetSearchListAsGrouped(SalaryAidSearchViewModel searchModel); #endregion } \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AssignProject/AssignProjectCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AssignProject/AssignProjectCommandHandler.cs index 7dddf33e..4dc48a24 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AssignProject/AssignProjectCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AssignProject/AssignProjectCommandHandler.cs @@ -2,6 +2,9 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Domain.SkillAgg.Repositories; diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AutoUpdateDeployStatus/AutoUpdateDeployStatusCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AutoUpdateDeployStatus/AutoUpdateDeployStatusCommand.cs index 66fce572..b12dbd47 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AutoUpdateDeployStatus/AutoUpdateDeployStatusCommand.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/AutoUpdateDeployStatus/AutoUpdateDeployStatusCommand.cs @@ -2,6 +2,7 @@ using System.Linq; using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using Microsoft.EntityFrameworkCore; diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeDeployStatusProject/ChangeDeployeStatusProjectComand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeDeployStatusProject/ChangeDeployeStatusProjectComand.cs index 06c75b4a..fc3f46d4 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeDeployStatusProject/ChangeDeployeStatusProjectComand.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeDeployStatusProject/ChangeDeployeStatusProjectComand.cs @@ -2,6 +2,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.ChangeDeployStatusProject; diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs index d6ea7e1e..d7640e4c 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/ChangeTaskPriority/ChangeTaskPriorityCommand.cs @@ -1,6 +1,8 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; @@ -69,7 +71,7 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler(); + var tasks = phase.Tasks?.ToList() ?? new List(); foreach (var t in tasks) { if (t.Priority != priority) @@ -89,10 +91,10 @@ public class ChangeTaskPriorityCommandHandler : IBaseCommandHandler(); + var phases = project.Phases?.ToList() ?? new List(); foreach (var phase in phases) { - var tasks = phase.Tasks?.ToList() ?? new List(); + var tasks = phase.Tasks?.ToList() ?? new List(); foreach (var t in tasks) { if (t.Priority != priority) diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs index ef4a4292..70c2e586 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProject/CreateProjectCommandHandler.cs @@ -3,6 +3,9 @@ using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain._Common.Exceptions; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProjectWithHierarchy/CreateProjectWithHierarchyCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProjectWithHierarchy/CreateProjectWithHierarchyCommandHandler.cs index 0a899924..9493a83a 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProjectWithHierarchy/CreateProjectWithHierarchyCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/CreateProjectWithHierarchy/CreateProjectWithHierarchyCommandHandler.cs @@ -2,6 +2,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using MediatR; diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommand.cs index b7ed7859..5ec6445e 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommand.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommand.cs @@ -1,5 +1,7 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application.Modules.Projects.DTOs; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject; @@ -15,4 +17,5 @@ public class SetTimeSectionTime public string Description { get; set; } public int Hours { get; set; } public int Minutes { get; set; } + public TaskSectionAdditionalTimeType Type { get; set; } } \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs index a9ca3a61..d303c8a2 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandHandler.cs @@ -4,6 +4,9 @@ using GozareshgirProgramManager.Application.Modules.Projects.DTOs; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain._Common.Exceptions; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Domain.SkillAgg.Repositories; @@ -369,7 +372,7 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler CreateAdditionalTimeNotes( - IEnumerable additionalTimes, + IEnumerable additionalTimes, Dictionary users, Guid taskId) { diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/CreateTaskSectionRevision/CreateTaskSectionRevisionCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/CreateTaskSectionRevision/CreateTaskSectionRevisionCommand.cs new file mode 100644 index 00000000..c5ad2249 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/CreateTaskSectionRevision/CreateTaskSectionRevisionCommand.cs @@ -0,0 +1,136 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs; +using GozareshgirProgramManager.Application.Services.FileManagement; +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.FileManagementAgg.Entities; +using GozareshgirProgramManager.Domain.FileManagementAgg.Enums; +using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; +using Microsoft.AspNetCore.Http; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision; + +public record CreateTaskSectionRevisionCommand(string Message, List Files, Guid SectionId) : IBaseCommand; + +public class CreateTaskSectionRevisionCommandHandler : IBaseCommandHandler +{ + private readonly ITaskSectionRevisionRepository _revisionRepository; + private readonly IFileStorageService _fileStorageService; + private readonly IAuthHelper _authHelper; + private readonly IUnitOfWork _unitOfWork; + private readonly IUploadedFileRepository _fileRepository; + private readonly IThumbnailGeneratorService _thumbnailService; + + public CreateTaskSectionRevisionCommandHandler(ITaskSectionRevisionRepository revisionRepository, + IFileStorageService fileStorageService, IAuthHelper authHelper, IUnitOfWork unitOfWork, IUploadedFileRepository fileRepository, IThumbnailGeneratorService thumbnailService) + { + _revisionRepository = revisionRepository; + _fileStorageService = fileStorageService; + _authHelper = authHelper; + _unitOfWork = unitOfWork; + _fileRepository = fileRepository; + _thumbnailService = thumbnailService; + } + + public async Task Handle(CreateTaskSectionRevisionCommand request, + CancellationToken cancellationToken) + { + var currentId = _authHelper.GetCurrentUserId(); + + var entity = new Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision(request.SectionId, request.Message, currentId!.Value); + if (request.Files is { Count: > 0 }) + { + foreach (var file in request.Files) + { + if (file.Length == 0) + { + return OperationResult.ValidationError("فایل خالی است"); + } + + const long maxFileSize = 100 * 1024 * 1024; + if (file.Length > maxFileSize) + { + return OperationResult.ValidationError("حجم فایل بیش از حد مجاز است (حداکثر 100MB)"); + } + + var fileType = DetectFileType(file.ContentType, Path.GetExtension(file.FileName)); + + var uploadedFile = new UploadedFile( + originalFileName: file.FileName, + fileSizeBytes: file.Length, + mimeType: file.ContentType, + fileType: fileType, + category: FileCategory.TaskSectionRevision, + uploadedByUserId: currentId!.Value, + storageProvider: StorageProvider.LocalFileSystem + ); + + await _fileRepository.AddAsync(uploadedFile); + await _fileRepository.SaveChangesAsync(); + + try + { + await using var stream = file.OpenReadStream(); + var uploadResult = await _fileStorageService.UploadAsync( + stream, + uploadedFile.UniqueFileName, + "TaskSectionRevision" + ); + + uploadedFile.CompleteUpload(uploadResult.StoragePath, uploadResult.StorageUrl); + + if (fileType == FileType.Image) + { + var dimensions = await _thumbnailService.GetImageDimensionsAsync(uploadResult.StoragePath); + if (dimensions.HasValue) + { + uploadedFile.SetImageDimensions(dimensions.Value.Width, dimensions.Value.Height); + } + + var thumbnail = await _thumbnailService + .GenerateImageThumbnailAsync(uploadResult.StoragePath, category: "TaskSectionRevision"); + if (thumbnail.HasValue) + { + uploadedFile.SetThumbnail(thumbnail.Value.ThumbnailUrl); + } + } + + await _fileRepository.UpdateAsync(uploadedFile); + await _fileRepository.SaveChangesAsync(); + + var taskRevisionFile = new TaskRevisionFile(uploadedFile.Id); + entity.AddFile(taskRevisionFile); + } + catch (Exception ex) + { + await _fileRepository.DeleteAsync(uploadedFile); + await _fileRepository.SaveChangesAsync(); + + return OperationResult.ValidationError($"خطا در آپلود فایل: {ex.Message}"); + } + } + } + + await _revisionRepository.CreateAsync(entity); + await _unitOfWork.SaveChangesAsync(cancellationToken); + return OperationResult.Success(); + } + private FileType DetectFileType(string mimeType, string extension) + { + if (mimeType.StartsWith("image/", StringComparison.OrdinalIgnoreCase)) + return FileType.Image; + + if (mimeType.StartsWith("video/", StringComparison.OrdinalIgnoreCase)) + return FileType.Video; + + if (mimeType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase)) + return FileType.Audio; + + if (new[] { ".zip", ".rar", ".7z", ".tar", ".gz" }.Contains(extension.ToLower())) + return FileType.Archive; + + return FileType.Document; + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/CreateTaskSectionRevision/CreateTaskSectionRevisionValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/CreateTaskSectionRevision/CreateTaskSectionRevisionValidator.cs new file mode 100644 index 00000000..4bd7ebcb --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/CreateTaskSectionRevision/CreateTaskSectionRevisionValidator.cs @@ -0,0 +1,14 @@ +using FluentValidation; +using Microsoft.EntityFrameworkCore.ChangeTracking; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision; + +public class CreateTaskSectionRevisionValidator:AbstractValidator +{ + public CreateTaskSectionRevisionValidator() + { + RuleFor(x=>x.Message) + .NotEmpty() + .WithMessage("توضیحات اجباری است"); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/SetStatusReviewedRevision/SetStatusReviewedRevisionCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/SetStatusReviewedRevision/SetStatusReviewedRevisionCommand.cs new file mode 100644 index 00000000..b30ec211 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Commands/SetStatusReviewedRevision/SetStatusReviewedRevisionCommand.cs @@ -0,0 +1,35 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.SetStatusReviewedRevision; + +public record SetStatusReviewedRevisionCommand(Guid TaskSectionId):IBaseCommand; + +public class SetStatusReviewedRevisionCommandHandler : IBaseCommandHandler +{ + private readonly ITaskSectionRevisionRepository _revisionRepository; + private readonly IUnitOfWork _unitOfWork; + + public SetStatusReviewedRevisionCommandHandler(ITaskSectionRevisionRepository revisionRepository, IUnitOfWork unitOfWork) + { + _revisionRepository = revisionRepository; + _unitOfWork = unitOfWork; + } + + public async Task Handle(SetStatusReviewedRevisionCommand request, CancellationToken cancellationToken) + { + var taskSectionRevisions = await _revisionRepository.GetByTaskSectionId(request.TaskSectionId); + if (taskSectionRevisions == null || taskSectionRevisions.Count == 0) + return OperationResult.NotFound("اصلاحی برای این بخش یافت نشد"); + + foreach (var revision in taskSectionRevisions) + { + revision.MarkReviewed(); + } + + await _unitOfWork.SaveChangesAsync(cancellationToken); + return OperationResult.Success(); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Queries/TaskRevisionsByTaskSectionId/TaskRevisionsByTaskSectionIdQuery.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Queries/TaskRevisionsByTaskSectionId/TaskRevisionsByTaskSectionIdQuery.cs new file mode 100644 index 00000000..d4988f58 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Queries/TaskRevisionsByTaskSectionId/TaskRevisionsByTaskSectionIdQuery.cs @@ -0,0 +1,92 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain._Common; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId; + +public record TaskRevisionsByTaskSectionIdQuery(Guid TaskSectionId) + : IBaseQuery; + +public class TaskRevisionsByTaskSectionIdQueryHandler : IBaseQueryHandler +{ + private readonly IProgramManagerDbContext _dbContext; + + public TaskRevisionsByTaskSectionIdQueryHandler(IProgramManagerDbContext dbContext) + { + _dbContext = dbContext; + } + + public async Task> Handle( + TaskRevisionsByTaskSectionIdQuery request, CancellationToken cancellationToken) + { + var taskSectionEntity = await _dbContext.TaskSections + .Include(x=>x.Task) + .ThenInclude(x => x.Phase) + .ThenInclude(x => x.Project) + .FirstOrDefaultAsync(x => x.Id == request.TaskSectionId, + cancellationToken: cancellationToken); + + if (taskSectionEntity == null) + { + return OperationResult.NotFound("بخش فرعی یافت نشد"); + } + + var taskRevisions = await _dbContext.TaskSectionRevisions + .Include(x => x.Files).Where(x => x.TaskSectionId == request.TaskSectionId) + .ToListAsync(cancellationToken); + if (taskRevisions.Count == 0) + { + return OperationResult.NotFound("اصلاحی یافت نشد"); + } + + var skill = await _dbContext.Skills.FirstOrDefaultAsync(x => x.Id == taskSectionEntity.SkillId, + cancellationToken: cancellationToken); + + if (skill == null) + return OperationResult.NotFound("مهارت مورد نظر یافت نشد"); + + + var user =await _dbContext.Users.FirstOrDefaultAsync(x => x.Id == taskSectionEntity.CurrentAssignedUserId, + cancellationToken: cancellationToken); + if (user == null) + return OperationResult.NotFound("کاربر مورد نظر یافت نشد"); + + var fileIds = taskRevisions.SelectMany(x => x.Files) + .Select(x => x.FileId).Distinct().ToList(); + + var uploadedFiles = _dbContext.UploadedFiles + .Where(x => fileIds.Contains(x.Id)).ToList(); + + var resItems = taskRevisions.Select(x => + { + var itemFileIds = x.Files.Select(f => f.FileId).Distinct().ToList(); + + var files = uploadedFiles + .Where(f => itemFileIds.Contains(f.Id)) + .Select(file => new TaskRevisionsByTaskSectionIdItemFile() + { + Id = file.Id, + FileName = file.OriginalFileName, + FileUrl = file.StorageUrl ?? "", + FileSizeBytes = file.FileSizeBytes, + FileType = file.FileType.ToString(), + ThumbnailUrl = file.ThumbnailUrl, + ImageWidth = file.ImageWidth, + ImageHeight = file.ImageHeight, + DurationSeconds = file.DurationSeconds + }).ToList(); + + return new TaskRevisionsByTaskSectionIdItem(x.Message, files,$"{x.CreationDate.ToFarsi()} {x.CreationDate:HH:mm}"); + }).ToList(); + + var res = new TaskRevisionsByTaskSectionIdResponse(resItems, taskSectionEntity.Task.Phase.Project.Name, + taskSectionEntity.Task.Phase.Name, taskSectionEntity.Task.Name, + skill.Name, + user.FullName + ); + + return OperationResult.Success(res); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Queries/TaskRevisionsByTaskSectionId/TaskRevisionsByTaskSectionIdResponse.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Queries/TaskRevisionsByTaskSectionId/TaskRevisionsByTaskSectionIdResponse.cs new file mode 100644 index 00000000..3fb128cd --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionRevision/Queries/TaskRevisionsByTaskSectionId/TaskRevisionsByTaskSectionIdResponse.cs @@ -0,0 +1,16 @@ +using GozareshgirProgramManager.Application._Common.Models; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId; + +public record TaskRevisionsByTaskSectionIdResponse( + List Items, + string ProjectName, + string PhaseName, + string TaskName, + string SkillName, + string UserName); + + +public record TaskRevisionsByTaskSectionIdItem(string Message, List Files,string CreationDate); + +public class TaskRevisionsByTaskSectionIdItemFile:UploadedFileDto; \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/AcceptTimeRequest/AcceptTimeRequestCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/AcceptTimeRequest/AcceptTimeRequestCommand.cs new file mode 100644 index 00000000..2fcd77f5 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/AcceptTimeRequest/AcceptTimeRequestCommand.cs @@ -0,0 +1,56 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest; + +public record AcceptTimeRequestCommand(Guid TimeRequestId, + Guid SectionId,TaskSectionAdditionalTimeType TimeType,int Hour,int Minute):IBaseCommand; + +public class AcceptTimeRequestCommandHandler:IBaseCommandHandler +{ + private readonly ITaskSectionTimeRequestRepository _timeRequestRepository; + private readonly ITaskSectionRepository _taskSectionRepository; + private readonly IUnitOfWork _unitOfWork; + public AcceptTimeRequestCommandHandler(ITaskSectionTimeRequestRepository timeRequestRepository, ITaskSectionRepository taskSectionRepository, IUnitOfWork unitOfWork) + { + _timeRequestRepository = timeRequestRepository; + _taskSectionRepository = taskSectionRepository; + _unitOfWork = unitOfWork; + } + + public async Task Handle(AcceptTimeRequestCommand request, CancellationToken cancellationToken) + { + var timeRequest = await _timeRequestRepository.GetByIdAsync(request.TimeRequestId, cancellationToken); + if (timeRequest == null) + { + return OperationResult.NotFound("درخواست زمان شما یافت نشد"); + } + + var taskSection = await _taskSectionRepository.GetByIdAsync(request.SectionId, cancellationToken); + + if (taskSection == null) + { + return OperationResult.NotFound("بخش فرعی وارد شده نامعتبر است"); + } + if (timeRequest.RequestStatus == TaskSectionTimeRequestStatus.Accepted) + { + return OperationResult.Failure("این درخواست قبلا تایید شده است"); + } + + // تایید درخواست زمان + timeRequest.AcceptTimeRequest(); + + // اضافه کردن زمان به TaskSection + var totalMinutes = (request.Hour * 60) + request.Minute; + var additionalTime = TimeSpan.FromMinutes(totalMinutes); + taskSection.AddAdditionalTime(additionalTime, request.TimeType, timeRequest.Description); + + await _unitOfWork.SaveChangesAsync(cancellationToken); + return OperationResult.Success(); + + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/AcceptTimeRequest/AcceptTimeRequestCommandValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/AcceptTimeRequest/AcceptTimeRequestCommandValidator.cs new file mode 100644 index 00000000..7d199891 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/AcceptTimeRequest/AcceptTimeRequestCommandValidator.cs @@ -0,0 +1,24 @@ +using FluentValidation; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest; + +public class AcceptTimeRequestCommandValidator : AbstractValidator +{ + public AcceptTimeRequestCommandValidator() + { + RuleFor(c => c.TimeRequestId) + .NotEmpty().WithMessage("شناسه درخواست نمیتواند خالی باشد"); + + RuleFor(c => c.SectionId) + .NotEmpty().WithMessage("شناسه بخش فرعی نمیتواند خالی باشد"); + + RuleFor(c => c.TimeType) + .NotNull().WithMessage("نوع زمان درخواست شده نامعتبر است") + .IsInEnum(); + + RuleFor(c => c.Hour) + .InclusiveBetween(0, 100).WithMessage("ساعت وارد شده میتواند بین 0 تا 100 باشد"); + RuleFor(c => c.Minute) + .InclusiveBetween(0, 60).WithMessage("دقیقه وارد شده میتواند بین 0 تا 60 باشد"); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestCommand.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestCommand.cs new file mode 100644 index 00000000..fa0bf44a --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestCommand.cs @@ -0,0 +1,52 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest; + +public record CreateTimeRequestCommand(int Hours, int Minutes, string Description, + TaskSectionTimeRequestType RequestType,Guid TaskSectionId) : IBaseCommand; + +public class CreateTimeRequestCommandHandler : IBaseCommandHandler +{ + private readonly IAuthHelper _authHelper; + private readonly ITaskSectionTimeRequestRepository _timeRequestRepository; + private readonly ITaskSectionRepository _taskSectionRepository; + private readonly IUnitOfWork _unitOfWork; + + public CreateTimeRequestCommandHandler + (ITaskSectionTimeRequestRepository timeRequestRepository, IAuthHelper authHelper, IUnitOfWork unitOfWork, ITaskSectionRepository taskSectionRepository) + { + _timeRequestRepository = timeRequestRepository; + _authHelper = authHelper; + _unitOfWork = unitOfWork; + _taskSectionRepository = taskSectionRepository; + } + + public async Task Handle(CreateTimeRequestCommand request, CancellationToken cancellationToken) + { + var currentUser = _authHelper.GetCurrentUserId(); + if (!currentUser.HasValue) + { + return OperationResult.Unauthorized(); + } + + if (!_taskSectionRepository.Exists(x=>x.Id == request.TaskSectionId)) + { + return OperationResult.NotFound("وظیفه فرعی مورد نظر یافت نشد"); + } + + + var requestTimeSpan = TimeSpan.FromHours(request.Hours) + TimeSpan.FromMinutes(request.Minutes); + + var entity = new TaskSectionTimeRequest(currentUser.Value, request.Description, requestTimeSpan, + request.RequestType,request.TaskSectionId); + await _timeRequestRepository.CreateAsync(entity); + await _unitOfWork.SaveChangesAsync(cancellationToken); + return OperationResult.Success(); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestValidator.cs new file mode 100644 index 00000000..82484ad0 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestValidator.cs @@ -0,0 +1,20 @@ +using FluentValidation; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest; + +public class CreateTimeRequestValidator : AbstractValidator +{ + public CreateTimeRequestValidator() + { + RuleFor(c => c.Hours) + .InclusiveBetween(0, 100).WithMessage("ساعت درخواست شده باید کمتر از 100 ساعت باشد"); + + RuleFor(c => c.Minutes) + .InclusiveBetween(0, 59) + .WithMessage("دقیقه وارد شده باید بین 0 تا 60 باشد"); + + RuleFor(x => x.RequestType) + .IsInEnum() + .NotNull(); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Queries/CreateTimeRequestDetails/CreateTimeRequestDetailsQuery.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Queries/CreateTimeRequestDetails/CreateTimeRequestDetailsQuery.cs new file mode 100644 index 00000000..6a2c7e18 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Queries/CreateTimeRequestDetails/CreateTimeRequestDetailsQuery.cs @@ -0,0 +1,49 @@ +using GozareshgirProgramManager.Application._Common.Extensions; +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Queries.CreateTimeRequestDetails; + +public record CreateTimeRequestDetailsResponse(List Revisions); + +public record CreateTimeRequestDetailsRevision(string Message, List Files); + +public record CreateTimeRequestDetailsQuery(Guid TaskSectionId) : IBaseQuery; + +public class + CreateTimeRequestDetailsQueryHandler : IBaseQueryHandler +{ + private readonly IProgramManagerDbContext _context; + + public CreateTimeRequestDetailsQueryHandler(IProgramManagerDbContext context) + { + _context = context; + } + + public async Task> Handle(CreateTimeRequestDetailsQuery request, + CancellationToken cancellationToken) + { + var revisions = await _context.TaskSectionRevisions.Where(x => + x.TaskSectionId == request.TaskSectionId && x.Status == RevisionReviewStatus.Pending).ToListAsync(cancellationToken: cancellationToken); + + var fileIds = revisions.SelectMany(x => x.Files) + .Select(x => x.Id).ToList(); + + var files =await _context.UploadedFiles + .Where(x => fileIds.Contains(x.Id)).ToListAsync(cancellationToken: cancellationToken); + + var resItem = revisions.Select(x => + { + var selectFileIds = x.Files.Select(f => f.FileId).ToList(); + var filesDto = files.Where(f => selectFileIds.Contains(f.Id)) + .Select(f => f.ToDto()).ToList(); + return new CreateTimeRequestDetailsRevision(x.Message, filesDto); + }).ToList(); + var res = new CreateTimeRequestDetailsResponse(resItem); + + return OperationResult.Success(res); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/IWorkflowProvider.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/IWorkflowProvider.cs new file mode 100644 index 00000000..1769e593 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/IWorkflowProvider.cs @@ -0,0 +1,11 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList; + +namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList; + +public interface IWorkflowProvider +{ + WorkflowType Type { get; } + Task> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken); + Task GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken); +} diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/BugSectionWorkflowProvider.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/BugSectionWorkflowProvider.cs new file mode 100644 index 00000000..f3366bda --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/BugSectionWorkflowProvider.cs @@ -0,0 +1,32 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers; + +public class BugSectionWorkflowProvider : IWorkflowProvider +{ + public WorkflowType Type => WorkflowType.BugSection; + public async Task> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken) + { + var bugs =context.BugSections + .Where(b=>b.Status == TaskSectionStatus.ReadyToStart) + .Include(x => x.ProjectTask).AsNoTracking(); + + return await bugs.Select(x => new WorkflowListItem + { + EntityId = x.Id, + Title = x.ProjectTask.Name, + Type = WorkflowType.BugSection + }).ToListAsync(cancellationToken); + + } + + public async Task GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken) + { + var query = context.BugSections + .Where(b => b.Status == TaskSectionStatus.ReadyToStart); + + return await query.CountAsync(cancellationToken); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/NotAssignedWorkflowProvider.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/NotAssignedWorkflowProvider.cs new file mode 100644 index 00000000..155f1c2a --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/NotAssignedWorkflowProvider.cs @@ -0,0 +1,31 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers; + +public class NotAssignedWorkflowProvider : IWorkflowProvider +{ + public WorkflowType Type => WorkflowType.NotAssigned; + + public async Task> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken) + { + // Assuming 0 means unassigned in CurrentAssignedUserId + var sections = await context.TaskSections + .Where(x => x.CurrentAssignedUserId == 0) + .ToListAsync(cancellationToken); + + return sections.Select(ts => new WorkflowListItem + { + EntityId = ts.Id, + Title = "تخصیص‌ نیافته", + Type = WorkflowType.NotAssigned + }).ToList(); + } + + public async Task GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken) + { + return await context.TaskSections + .Where(x => x.CurrentAssignedUserId == 0) + .CountAsync(cancellationToken); + } +} diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/RejectedRevisionsWorkflowProvider.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/RejectedRevisionsWorkflowProvider.cs new file mode 100644 index 00000000..719a1b2f --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/Providers/RejectedRevisionsWorkflowProvider.cs @@ -0,0 +1,41 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers; + +public class RejectedRevisionsWorkflowProvider : IWorkflowProvider +{ + public WorkflowType Type => WorkflowType.Rejected; + + public async Task> GetItems(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken) + { + var query = from revision in context.TaskSectionRevisions + .Where(x => x.Status == RevisionReviewStatus.Pending) + join taskSection in context.TaskSections + on revision.TaskSectionId equals taskSection.Id + where taskSection.CurrentAssignedUserId == currentUserId + select taskSection; + + var sections = await query.ToListAsync(cancellationToken); + + return sections.Select(ts => new WorkflowListItem + { + EntityId = ts.Id, + Title = "برگشت از سمت مدیر", + Type = WorkflowType.Rejected + }).ToList(); + } + + public async Task GetCount(long currentUserId, IProgramManagerDbContext context, CancellationToken cancellationToken) + { + var query = from revision in context.TaskSectionRevisions + .Where(x => x.Status == RevisionReviewStatus.Pending) + join taskSection in context.TaskSections + on revision.TaskSectionId equals taskSection.Id + where taskSection.CurrentAssignedUserId == currentUserId + select revision.Id; + + return await query.CountAsync(cancellationToken); + } +} diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/WorkflowCountQuery.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/WorkflowCountQuery.cs new file mode 100644 index 00000000..0de756bd --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/WorkflowCountQuery.cs @@ -0,0 +1,50 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers; + +namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList; + +public record WorkflowCountResponse(int Total, int Rejected, int NotAssigned, int PendingForApproval); + +public record WorkflowCountQuery() : IBaseQuery; + +public class WorkflowCountQueryHandler : IBaseQueryHandler +{ + private readonly IProgramManagerDbContext _context; + private readonly IAuthHelper _authHelper; + private readonly IEnumerable _providers; + + public WorkflowCountQueryHandler(IProgramManagerDbContext context, IAuthHelper authHelper, IEnumerable providers) + { + _context = context; + _authHelper = authHelper; + _providers = providers; + } + + public async Task> Handle(WorkflowCountQuery request, CancellationToken cancellationToken) + { + long currentUserId = _authHelper.GetCurrentUserId()!.Value; + + int rejectedCount = 0; + int notAssignedCount = 0; + int pendingForApprovalCount = 0; + + foreach (var provider in _providers) + { + var count = await provider.GetCount(currentUserId, _context, cancellationToken); + switch (provider.Type) + { + case WorkflowType.Rejected: + rejectedCount += count; break; + case WorkflowType.NotAssigned: + notAssignedCount += count; break; + case WorkflowType.PendingForApproval: + pendingForApprovalCount += count; break; + } + } + + var total = rejectedCount + notAssignedCount + pendingForApprovalCount; + var response = new WorkflowCountResponse(total, rejectedCount, notAssignedCount, pendingForApprovalCount); + return OperationResult.Success(response); + } +} diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/WorkflowListQuery.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/WorkflowListQuery.cs new file mode 100644 index 00000000..e50be2b4 --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Workflows/Queries/WorkflowList/WorkflowListQuery.cs @@ -0,0 +1,56 @@ +using GozareshgirProgramManager.Application._Common.Interfaces; +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers; + +namespace GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList; + +public record WorkflowListResponse(ListItems); + +public class WorkflowListItem +{ + public string Title { get; set; } + public WorkflowType Type { get; set; } + public Guid EntityId { get; set; } +} + +public enum WorkflowType +{ + Rejected, + NotAssigned, + PendingForApproval, + BugSection, +} + +public record WorkflowListQuery():IBaseQuery; + +public class WorkflowListQueryHandler:IBaseQueryHandler +{ + private readonly IProgramManagerDbContext _context; + private readonly IAuthHelper _authHelper; + private readonly IEnumerable _providers; + + public WorkflowListQueryHandler(IProgramManagerDbContext context, + IAuthHelper authHelper, + IEnumerable providers) + { + _context = context; + _authHelper = authHelper; + _providers = providers; + } + + public async Task> Handle(WorkflowListQuery request, CancellationToken cancellationToken) + { + var currentUserId = _authHelper.GetCurrentUserId()!.Value; + var items = new List(); + var response = new WorkflowListResponse(items); + foreach (var provider in _providers) + { + var providerItems = await provider.GetItems(currentUserId, _context, cancellationToken); + if (providerItems?.Count > 0) + items.AddRange(providerItems); + } + + return OperationResult.Success(response); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Extensions/FileExtensions.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Extensions/FileExtensions.cs new file mode 100644 index 00000000..018ad5bd --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Extensions/FileExtensions.cs @@ -0,0 +1,23 @@ +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Domain.FileManagementAgg.Entities; + +namespace GozareshgirProgramManager.Application._Common.Extensions; + +public static class FileExtensions +{ + public static UploadedFileDto ToDto(this UploadedFile file) + { + return new UploadedFileDto() + { + Id = file.Id, + FileName = file.OriginalFileName, + FileUrl = file.StorageUrl ?? "", + FileSizeBytes = file.FileSizeBytes, + FileType = file.FileType.ToString(), + ThumbnailUrl = file.ThumbnailUrl, + ImageWidth = file.ImageWidth, + ImageHeight = file.ImageHeight, + DurationSeconds = file.DurationSeconds + }; + } +} \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Interfaces/IProgramManagerDbContext.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Interfaces/IProgramManagerDbContext.cs index 9d3aeefa..b2f35974 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Interfaces/IProgramManagerDbContext.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Interfaces/IProgramManagerDbContext.cs @@ -9,6 +9,10 @@ using GozareshgirProgramManager.Domain.UserAgg.Entities; using Microsoft.EntityFrameworkCore; using GozareshgirProgramManager.Domain.TaskChatAgg.Entities; using GozareshgirProgramManager.Domain.FileManagementAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; namespace GozareshgirProgramManager.Application._Common.Interfaces; @@ -31,6 +35,12 @@ public interface IProgramManagerDbContext DbSet TaskChatMessages { get; set; } DbSet UploadedFiles { get; set; } + //Task Section Time Request + DbSet TaskSectionTimeRequests { get; set; } + + // Task Section Revision + DbSet TaskSectionRevisions { get; set; } + DbSet Skills { get; set; } Task SaveChangesAsync(CancellationToken cancellationToken = default); } diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/OperationResult.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/OperationResult.cs index 324e9895..e92e0df6 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/OperationResult.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/OperationResult.cs @@ -31,7 +31,7 @@ public class OperationResult // Helper methods for specific error types public static OperationResult NotFound(string errorMessage) => new(false, errorMessage, errorType: ErrorType.NotFound); - public static OperationResult Unauthorized(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Unauthorized); + public static OperationResult Unauthorized(string errorMessage="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") => new(false, errorMessage, errorType: ErrorType.Unauthorized); public static OperationResult ValidationError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.Validation); public static OperationResult ValidationError(List errors) => new(false, errors: errors, errorType: ErrorType.Validation); public static OperationResult InternalServerError(string errorMessage) => new(false, errorMessage, errorType: ErrorType.InternalServerError); diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/UploadedFileDto.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/UploadedFileDto.cs new file mode 100644 index 00000000..a9a0264d --- /dev/null +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/_Common/Models/UploadedFileDto.cs @@ -0,0 +1,34 @@ +namespace GozareshgirProgramManager.Application._Common.Models; + +public class UploadedFileDto +{ + + public Guid Id { get; set; } + public string FileName { get; set; } = string.Empty; + public string FileUrl { get; set; } = string.Empty; + public long FileSizeBytes { get; set; } + public string FileType { get; set; } = string.Empty; + public string? ThumbnailUrl { get; set; } + public int? ImageWidth { get; set; } + public int? ImageHeight { get; set; } + public int? DurationSeconds { get; set; } + + public string FileSizeFormatted + { + get + { + const long kb = 1024; + const long mb = kb * 1024; + const long gb = mb * 1024; + + if (FileSizeBytes >= gb) + return $"{FileSizeBytes / (double)gb:F2} GB"; + if (FileSizeBytes >= mb) + return $"{FileSizeBytes / (double)mb:F2} MB"; + if (FileSizeBytes >= kb) + return $"{FileSizeBytes / (double)kb:F2} KB"; + + return $"{FileSizeBytes} Bytes"; + } + } +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/FileManagementAgg/Enums/FileCategory.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/FileManagementAgg/Enums/FileCategory.cs index 3bb774d5..176e68fb 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/FileManagementAgg/Enums/FileCategory.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/FileManagementAgg/Enums/FileCategory.cs @@ -12,5 +12,6 @@ public enum FileCategory Report = 5, // گزارش Other = 6, // سایر BugSection = 7, // تسک باگ + TaskSectionRevision } diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/BugSection.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/BugSection.cs index cbb79db8..ccb2bfac 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/BugSection.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/BugSection.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/PhaseSection.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Phase/PhaseSection.cs similarity index 93% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/PhaseSection.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Phase/PhaseSection.cs index 05c7bb83..374bcbfd 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/PhaseSection.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Phase/PhaseSection.cs @@ -1,7 +1,7 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.SkillAgg.Entities; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; /// /// بخش فاز - برای ذخیره تخصیص کاربر و مهارت در سطح Phase diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectPhase.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Phase/ProjectPhase.cs similarity index 95% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectPhase.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Phase/ProjectPhase.cs index 129c5ff4..f0ce7306 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectPhase.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Phase/ProjectPhase.cs @@ -1,8 +1,9 @@ -using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Events; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; /// /// فاز پروژه - سطح میانی در سلسله مراتب @@ -28,7 +29,7 @@ public class ProjectPhase : ProjectHierarchyNode } public Guid ProjectId { get; private set; } - public Project Project { get; private set; } = null!; + public Project.Project Project { get; private set; } = null!; public IReadOnlyList Tasks => _tasks.AsReadOnly(); public IReadOnlyList PhaseSections => _phaseSections.AsReadOnly(); diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project/Project.cs similarity index 97% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project/Project.cs index 8e8e2b31..f1ed9816 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project/Project.cs @@ -1,8 +1,8 @@ -using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Events; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; /// /// پروژه - بالاترین سطح در سلسله مراتب و Aggregate Root diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectSection.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project/ProjectSection.cs similarity index 92% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectSection.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project/ProjectSection.cs index d41c5eb0..b6d10943 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectSection.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Project/ProjectSection.cs @@ -1,7 +1,7 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.SkillAgg.Entities; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; /// /// ProjectSection: shortcut container for UserId + SkillId at Project level diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/ProjectTask.cs similarity index 89% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/ProjectTask.cs index 76973230..685a4574 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/ProjectTask.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/ProjectTask.cs @@ -1,25 +1,25 @@ -using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Events; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; /// /// تسک - پایین‌ترین سطح در سلسله مراتب که شامل بخش‌ها می‌شود /// public class ProjectTask : ProjectHierarchyNode { - private readonly List _sections; + private readonly List _sections; private ProjectTask() { - _sections = new List(); + _sections = new List(); } public ProjectTask(string name, Guid phaseId,ProjectTaskPriority priority, string? description = null) : base(name, description) { PhaseId = phaseId; - _sections = new List(); + _sections = new List(); BugSectionList = new List(); Priority = priority; AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name)); @@ -27,7 +27,7 @@ public class ProjectTask : ProjectHierarchyNode public Guid PhaseId { get; private set; } public ProjectPhase Phase { get; private set; } = null!; - public IReadOnlyList Sections => _sections.AsReadOnly(); + public IReadOnlyList Sections => _sections.AsReadOnly(); public List BugSectionList { get; set; } // Task-specific properties @@ -42,7 +42,7 @@ public class ProjectTask : ProjectHierarchyNode #region Section Management - public void AddSection(TaskSection section, bool cascadeToChildren = false) + public void AddSection(TaskSection.TaskSection section, bool cascadeToChildren = false) { var existingSection = _sections.FirstOrDefault(s => s.SkillId == section.SkillId); if (existingSection != null) @@ -86,7 +86,7 @@ public class ProjectTask : ProjectHierarchyNode return; } - var section = new TaskSection(Id, skillId, assignedUserId); + var section = new TaskSection.TaskSection(Id, skillId, assignedUserId); _sections.Add(section); AddDomainEvent(new TaskSectionAddedEvent(Id, section.Id, skillId)); } @@ -206,12 +206,12 @@ public class ProjectTask : ProjectHierarchyNode #region Query Helpers - public IEnumerable GetSectionsBySkill(Guid skillId) + public IEnumerable GetSectionsBySkill(Guid skillId) { return _sections.Where(s => s.SkillId == skillId); } - public TaskSection? GetSectionBySkill(Guid skillId) + public TaskSection.TaskSection? GetSectionBySkill(Guid skillId) { return _sections.FirstOrDefault(s => s.SkillId == skillId); } @@ -221,7 +221,7 @@ public class ProjectTask : ProjectHierarchyNode return _sections.Any(s => s.SkillId == skillId); } - public IEnumerable GetAssignedSections(long userId) + public IEnumerable GetAssignedSections(long userId) { return _sections.Where(s => s.CurrentAssignedUserId == userId); } diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSection.cs similarity index 96% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSection.cs index 83b86c23..3c1543ba 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSection.cs @@ -1,12 +1,10 @@ -using System.Linq; -using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain._Common.Exceptions; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Events; -using GozareshgirProgramManager.Domain.ProjectAgg.Models; using GozareshgirProgramManager.Domain.SkillAgg.Entities; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; /// /// بخش تسک - برای ذخیره کار واقعی که کاربر روی یک مهارت خاص انجام می‌دهد @@ -61,12 +59,13 @@ public class TaskSection : EntityBase // برای backward compatibility public TimeSpan EstimatedHours => FinalEstimatedHours; - public void AddAdditionalTime(TimeSpan additionalHours, string? reason = null, long? addedByUserId = null) + public void AddAdditionalTime(TimeSpan additionalHours, TaskSectionAdditionalTimeType type, string? reason = null, + long? addedByUserId = null) { if (additionalHours <= TimeSpan.Zero) throw new BadRequestException("تایم اضافی باید بزرگتر از صفر باشد", nameof(additionalHours)); - var additionalTime = new TaskSectionAdditionalTime(additionalHours, reason, addedByUserId); + var additionalTime = new TaskSectionAdditionalTime(additionalHours,type, reason, addedByUserId); _additionalTimes.Add(additionalTime); } diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionActivity.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionActivity.cs similarity index 95% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionActivity.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionActivity.cs index 04b3a7e3..a1cea634 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionActivity.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionActivity.cs @@ -1,7 +1,6 @@ -using System.Diagnostics.CodeAnalysis; using GozareshgirProgramManager.Domain._Common; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; /// /// فعالیت کاری روی یک بخش diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionAdditionalTime.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionAdditionalTime.cs similarity index 60% rename from ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionAdditionalTime.cs rename to ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionAdditionalTime.cs index 657f76cc..4a98c45c 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionAdditionalTime.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionAdditionalTime.cs @@ -1,6 +1,6 @@ using GozareshgirProgramManager.Domain._Common; -namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities; +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; /// /// زمان اضافی اضافه شده بعد از تخمین اولیه @@ -9,12 +9,13 @@ public class TaskSectionAdditionalTime : EntityBase { private TaskSectionAdditionalTime() { } - public TaskSectionAdditionalTime(TimeSpan hours, string? reason = null, long? addedByUserId = null) + public TaskSectionAdditionalTime(TimeSpan hours, TaskSectionAdditionalTimeType type, string? reason = null,long? addedByUserId = null) { Hours = hours; Reason = reason; AddedByUserId = addedByUserId; - AddedAt = DateTime.UtcNow; + AddedAt = DateTime.Now; + Type = type; } public TimeSpan Hours { get; private set; } @@ -22,8 +23,15 @@ public class TaskSectionAdditionalTime : EntityBase public long? AddedByUserId { get; private set; } public DateTime AddedAt { get; private set; } + public TaskSectionAdditionalTimeType Type { get; set; } public void UpdateReason(string? reason) { Reason = reason; } } + +public enum TaskSectionAdditionalTimeType +{ + Effective, + Ineffective, +} diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionRevision.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionRevision.cs new file mode 100644 index 00000000..41a8f761 --- /dev/null +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionRevision.cs @@ -0,0 +1,56 @@ +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.FileManagementAgg.Entities; + +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; + +public class TaskSectionRevision : EntityBase +{ + public TaskSectionRevision(Guid taskSectionId, + string message, long createdByUserId) + { + TaskSectionId = taskSectionId; + Status = RevisionReviewStatus.Pending; + Message = message; + CreatedByUserId = createdByUserId; + } + + public Guid TaskSectionId { get; private set; } + + public RevisionReviewStatus Status { get; private set; } + + + public string Message { get; private set; } + + public long CreatedByUserId { get; private set; } + + public IReadOnlyCollection Files => _files; + private readonly List _files = new(); + + public void AddFile(TaskRevisionFile file) + { + _files.Add(file); + } + + public void MarkReviewed() + { + if (Status == RevisionReviewStatus.Reviewed) + return; + Status = RevisionReviewStatus.Reviewed; + } + +} +public class TaskRevisionFile: EntityBase +{ + public TaskRevisionFile(Guid fileId) + { + FileId = fileId; + } + + public Guid FileId { get; private set; } +} + +public enum RevisionReviewStatus : short +{ + Pending = 1, + Reviewed = 2 +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionTimeRequest.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionTimeRequest.cs new file mode 100644 index 00000000..dba90501 --- /dev/null +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/Task/TaskSection/TaskSectionTimeRequest.cs @@ -0,0 +1,33 @@ +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; + +namespace GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; + +public class TaskSectionTimeRequest:EntityBase +{ + + public TaskSectionTimeRequest(long userId, string description, + TimeSpan requestedTime, TaskSectionTimeRequestType requestType, + Guid taskSectionId) + { + UserId = userId; + Description = description; + RequestedTime = requestedTime; + RequestType = requestType; + TaskSectionId = taskSectionId; + RequestStatus = TaskSectionTimeRequestStatus.Pending; + } + + public TaskSection TaskSection { get; set; } + public Guid TaskSectionId { get; set; } + public long UserId { get; private set; } + public string Description { get; private set; } + public TimeSpan RequestedTime { get; private set; } + public TaskSectionTimeRequestType RequestType { get; private set; } + public TaskSectionTimeRequestStatus RequestStatus { get; private set; } + + public void AcceptTimeRequest() + { + RequestStatus = TaskSectionTimeRequestStatus.Accepted; + } +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Enums/TaskSectionTimeRequestStatus.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Enums/TaskSectionTimeRequestStatus.cs new file mode 100644 index 00000000..6300b35e --- /dev/null +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Enums/TaskSectionTimeRequestStatus.cs @@ -0,0 +1,8 @@ +namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums; + +public enum TaskSectionTimeRequestStatus +{ + Pending, + Accepted, + Rejected +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Enums/TaskSectionTimeRequestType.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Enums/TaskSectionTimeRequestType.cs new file mode 100644 index 00000000..9c8007f7 --- /dev/null +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Enums/TaskSectionTimeRequestType.cs @@ -0,0 +1,8 @@ +namespace GozareshgirProgramManager.Domain.ProjectAgg.Enums; + +public enum TaskSectionTimeRequestType +{ + InitialTime, + AdditionalTime, + RejectedTime, +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IPhaseSectionRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IPhaseSectionRepository.cs index db8fb7e1..1ec69b1a 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IPhaseSectionRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IPhaseSectionRepository.cs @@ -1,5 +1,7 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; + namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; public interface IPhaseSectionRepository : IRepository { diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectPhaseRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectPhaseRepository.cs index 8a29e014..059a8fc7 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectPhaseRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectPhaseRepository.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectRepository.cs index 5514e492..013ce727 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectRepository.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectSectionRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectSectionRepository.cs index 2838c8d6..6f87295b 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectSectionRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectSectionRepository.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectTaskRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectTaskRepository.cs index 9894a764..5aada92c 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectTaskRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/IProjectTaskRepository.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionActivityRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionActivityRepository.cs index 55eff1be..0c0a1179 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionActivityRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionActivityRepository.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRepository.cs index 50e1a2b0..b194f804 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRepository.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRepository.cs @@ -1,6 +1,7 @@ using System.Collections; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRevisionRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRevisionRepository.cs new file mode 100644 index 00000000..491b8551 --- /dev/null +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionRevisionRepository.cs @@ -0,0 +1,9 @@ +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; + +namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; + +public interface ITaskSectionRevisionRepository:IRepository +{ + Task> GetByTaskSectionId(Guid requestTaskSectionId); +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionTimeRequestRepository.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionTimeRequestRepository.cs new file mode 100644 index 00000000..913221ac --- /dev/null +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Repositories/ITaskSectionTimeRequestRepository.cs @@ -0,0 +1,10 @@ +using GozareshgirProgramManager.Domain._Common; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; + +namespace GozareshgirProgramManager.Domain.ProjectAgg.Repositories; + +public interface ITaskSectionTimeRequestRepository:IRepository +{ + +} \ No newline at end of file diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/SkillAgg/Entities/Skill.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/SkillAgg/Entities/Skill.cs index 662f9544..0254b23e 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/SkillAgg/Entities/Skill.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/SkillAgg/Entities/Skill.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; namespace GozareshgirProgramManager.Domain.SkillAgg.Entities; diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/_Common/Exceptions/UnAuthorizedException.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/_Common/Exceptions/UnAuthorizedException.cs index 67f0befb..f470b20c 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/_Common/Exceptions/UnAuthorizedException.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/_Common/Exceptions/UnAuthorizedException.cs @@ -2,7 +2,7 @@ public class UnAuthorizedException:Exception { - public UnAuthorizedException(string message) : base(message) + public UnAuthorizedException(string message="احراز هویت شما منقضی شده است. لطفا دوباره وارد شوید") : base(message) { } } \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/DependencyInjection.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/DependencyInjection.cs index 3b4a1ed7..ec54f576 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/DependencyInjection.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/DependencyInjection.cs @@ -1,7 +1,3 @@ - - - -using FluentValidation; using GozareshgirProgramManager.Application._Common.Behaviors; using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application.Services.FileManagement; @@ -11,10 +7,7 @@ using GozareshgirProgramManager.Domain.CustomerAgg.Repositories; using GozareshgirProgramManager.Domain.FileManagementAgg.Repositories; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Domain.RoleAgg.Repositories; -using GozareshgirProgramManager.Domain.RoleAgg.Repositories; using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories; -using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories; -using GozareshgirProgramManager.Domain.SkillAgg.Repositories; using GozareshgirProgramManager.Domain.SkillAgg.Repositories; using GozareshgirProgramManager.Domain.TaskChatAgg.Repositories; using GozareshgirProgramManager.Domain.UserAgg.Repositories; @@ -32,6 +25,9 @@ using Shared.Contracts.PmRole.Commands; using Shared.Contracts.PmRole.Queries; using Shared.Contracts.PmUser.Commands; using Shared.Contracts.PmUser.Queries; +using System.Reflection; +using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList; +using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList.Providers; namespace GozareshgirProgramManager.Infrastructure; @@ -102,7 +98,12 @@ public static class DependencyInjection services.AddScoped(); services.AddScoped(); + + //TaskSection Time Request + services.AddScoped(); + //TaskSection Revision + services.AddScoped(); #region ServicesInjection @@ -118,6 +119,16 @@ public static class DependencyInjection // MediatR Validation Behavior services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); + // Workflow providers: auto-register all IWorkflowProvider implementations in the Application assembly + var appAssembly = typeof(IWorkflowProvider).Assembly; + var providerTypes = appAssembly + .GetTypes() + .Where(t => !t.IsAbstract && !t.IsInterface && typeof(IWorkflowProvider).IsAssignableFrom(t)) + .ToList(); + foreach (var providerType in providerTypes) + { + services.AddScoped(typeof(IWorkflowProvider), providerType); + } return services; } diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/20260122100032_Add time Request and Task section revision.Designer.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/20260122100032_Add time Request and Task section revision.Designer.cs new file mode 100644 index 00000000..5e92b274 --- /dev/null +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/20260122100032_Add time Request and Task section revision.Designer.cs @@ -0,0 +1,1198 @@ +// +using System; +using GozareshgirProgramManager.Infrastructure.Persistence.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace GozareshgirProgramManager.Infrastructure.Migrations +{ + [DbContext(typeof(ProgramManagerDbContext))] + [Migration("20260122100032_Add time Request and Task section revision")] + partial class AddtimeRequestandTasksectionrevision + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.CheckoutAgg.Entities.Checkout", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CheckoutEndDate") + .HasColumnType("datetime2"); + + b.Property("CheckoutStartDate") + .HasColumnType("datetime2"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DeductionFromSalary") + .HasColumnType("float"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("MandatoryHours") + .HasColumnType("int"); + + b.Property("Month") + .HasColumnType("int"); + + b.Property("MonthlySalaryDefined") + .HasColumnType("float"); + + b.Property("MonthlySalaryPay") + .HasColumnType("float"); + + b.Property("RemainingHours") + .HasColumnType("int"); + + b.Property("TotalDaysWorked") + .HasColumnType("int"); + + b.Property("TotalHoursWorked") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("Year") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Checkouts", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.CustomerAgg.Customer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("Customers", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.FileManagementAgg.Entities.UploadedFile", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DeletedByUserId") + .HasColumnType("bigint"); + + b.Property("DeletedDate") + .HasColumnType("datetime2"); + + b.Property("DurationSeconds") + .HasColumnType("int"); + + b.Property("FileExtension") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FileSizeBytes") + .HasColumnType("bigint"); + + b.Property("FileType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ImageHeight") + .HasColumnType("int"); + + b.Property("ImageWidth") + .HasColumnType("int"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsVirusScanPassed") + .HasColumnType("bit"); + + b.Property("MimeType") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("OriginalFileName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("ReferenceEntityId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ReferenceEntityType") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StoragePath") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("StorageProvider") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StorageUrl") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ThumbnailUrl") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("UniqueFileName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UploadDate") + .HasColumnType("datetime2"); + + b.Property("UploadedByUserId") + .HasColumnType("bigint"); + + b.Property("VirusScanDate") + .HasColumnType("datetime2"); + + b.Property("VirusScanResult") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("Category"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("Status"); + + b.HasIndex("UniqueFileName") + .IsUnique(); + + b.HasIndex("UploadedByUserId"); + + b.HasIndex("ReferenceEntityType", "ReferenceEntityId"); + + b.ToTable("UploadedFiles", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.PhaseSection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PhaseId") + .HasColumnType("uniqueidentifier"); + + b.Property("SkillId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PhaseId"); + + b.HasIndex("SkillId"); + + b.ToTable("PhaseSections"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DeployStatus") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("HasAssignmentOverride") + .HasColumnType("bit"); + + b.Property("IsArchived") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("OrderIndex") + .HasColumnType("int"); + + b.Property("ProjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ProjectId"); + + b.ToTable("ProjectPhases", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("HasAssignmentOverride") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlannedEndDate") + .HasColumnType("datetime2"); + + b.Property("PlannedStartDate") + .HasColumnType("datetime2"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Projects", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.ProjectSection", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ProjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("SkillId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProjectId"); + + b.HasIndex("SkillId"); + + b.ToTable("ProjectSections"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AllocatedTime") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("DueDate") + .HasColumnType("datetime2"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("HasAssignmentOverride") + .HasColumnType("bit"); + + b.Property("HasTimeOverride") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("OrderIndex") + .HasColumnType("int"); + + b.Property("PhaseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Priority") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("PhaseId"); + + b.ToTable("ProjectTasks", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("CurrentAssignedUserId") + .HasColumnType("bigint"); + + b.Property("InitialDescription") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("InitialEstimatedHours") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("OriginalAssignedUserId") + .HasColumnType("bigint"); + + b.Property("SkillId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TaskId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SkillId"); + + b.HasIndex("TaskId"); + + b.ToTable("TaskSections", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionActivity", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("EndNotes") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("SectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("SectionId"); + + b.ToTable("TaskSectionActivities", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionAdditionalTime", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AddedAt") + .HasColumnType("datetime2"); + + b.Property("AddedByUserId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Hours") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("TaskSectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("TaskSectionId"); + + b.ToTable("TaskSectionAdditionalTimes", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TaskSectionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TaskSectionRevisions"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionTimeRequest", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1200) + .HasColumnType("nvarchar(1200)"); + + b.Property("RequestStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequestedTime") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskSectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TaskSectionId"); + + b.ToTable("TaskSectionTimeRequests"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.RoleAgg.Entities.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("GozareshgirRoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("PmRoles", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities.SalaryPaymentSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("EndSettingDate") + .HasColumnType("datetime2"); + + b.Property("HolidayWorking") + .HasColumnType("bit"); + + b.Property("MonthlySalary") + .HasColumnType("float"); + + b.Property("StartSettingDate") + .HasColumnType("datetime2"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("SalaryPaymentSetting", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.ToTable("Skills", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.TaskChatAgg.Entities.TaskChatMessage", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DeletedDate") + .HasColumnType("datetime2"); + + b.Property("EditedDate") + .HasColumnType("datetime2"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsEdited") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsPinned") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("MessageType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PinnedByUserId") + .HasColumnType("bigint"); + + b.Property("PinnedDate") + .HasColumnType("datetime2"); + + b.Property("ReplyToMessageId") + .HasColumnType("uniqueidentifier"); + + b.Property("SenderUserId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("uniqueidentifier"); + + b.Property("TextContent") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.HasKey("Id"); + + b.HasIndex("CreationDate"); + + b.HasIndex("FileId"); + + b.HasIndex("IsDeleted"); + + b.HasIndex("ReplyToMessageId"); + + b.HasIndex("SenderUserId"); + + b.HasIndex("TaskId"); + + b.HasIndex("TaskId", "IsPinned"); + + b.ToTable("TaskChatMessages", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.UserAgg.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ProfilePhotoPath") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("Id"); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.UserAgg.Entities.UserRefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("IpAddress") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RevokedAt") + .HasColumnType("datetime2"); + + b.Property("Token") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserAgent") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ExpiresAt"); + + b.HasIndex("Token") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("UserRefreshTokens", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.PhaseSection", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", "Phase") + .WithMany("PhaseSections") + .HasForeignKey("PhaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Phase"); + + b.Navigation("Skill"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", "Project") + .WithMany("Phases") + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.ProjectSection", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", "Project") + .WithMany("ProjectSections") + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", "Skill") + .WithMany() + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Project"); + + b.Navigation("Skill"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", "Phase") + .WithMany("Tasks") + .HasForeignKey("PhaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Phase"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b => + { + b.HasOne("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", "Skill") + .WithMany("Sections") + .HasForeignKey("SkillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", "Task") + .WithMany("Sections") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Skill"); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionActivity", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", "Section") + .WithMany("Activities") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionAdditionalTime", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", null) + .WithMany("AdditionalTimes") + .HasForeignKey("TaskSectionId"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision", b => + { + b.OwnsMany("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskRevisionFile", "Files", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CreationDate") + .HasColumnType("datetime2"); + + b1.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b1.Property("TaskSectionRevisionId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("FileId"); + + b1.HasIndex("TaskSectionRevisionId"); + + b1.ToTable("TaskRevisionFile"); + + b1.HasOne("GozareshgirProgramManager.Domain.FileManagementAgg.Entities.UploadedFile", null) + .WithMany() + .HasForeignKey("FileId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("TaskSectionRevisionId"); + }); + + b.Navigation("Files"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionTimeRequest", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", "TaskSection") + .WithMany() + .HasForeignKey("TaskSectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskSection"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.RoleAgg.Entities.Role", b => + { + b.OwnsMany("GozareshgirProgramManager.Domain.PermissionAgg.Entities.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("PmRolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities.SalaryPaymentSetting", b => + { + b.OwnsMany("GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities.WorkingHours", "WorkingHoursList", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("EndShiftOne") + .HasColumnType("time(0)"); + + b1.Property("EndShiftTwo") + .HasColumnType("time(0)"); + + b1.Property("HasRestTime") + .HasColumnType("bit"); + + b1.Property("HasShiftOne") + .HasColumnType("bit"); + + b1.Property("HasShiftTow") + .HasColumnType("bit"); + + b1.Property("IsActiveDay") + .HasColumnType("bit"); + + b1.Property("PersianDayOfWeek") + .HasColumnType("int"); + + b1.Property("RestTime") + .HasColumnType("time(0)"); + + b1.Property("SalaryPaymentSettingId") + .HasColumnType("bigint"); + + b1.Property("ShiftDurationInMinutes") + .HasColumnType("int"); + + b1.Property("StartShiftOne") + .HasColumnType("time(0)"); + + b1.Property("StartShiftTwo") + .HasColumnType("time(0)"); + + b1.HasKey("Id"); + + b1.HasIndex("SalaryPaymentSettingId"); + + b1.ToTable("WorkingHours", (string)null); + + b1.WithOwner("SalaryPaymentSetting") + .HasForeignKey("SalaryPaymentSettingId"); + + b1.Navigation("SalaryPaymentSetting"); + }); + + b.Navigation("WorkingHoursList"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.TaskChatAgg.Entities.TaskChatMessage", b => + { + b.HasOne("GozareshgirProgramManager.Domain.TaskChatAgg.Entities.TaskChatMessage", "ReplyToMessage") + .WithMany() + .HasForeignKey("ReplyToMessageId") + .OnDelete(DeleteBehavior.NoAction); + + b.Navigation("ReplyToMessage"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.UserAgg.Entities.User", b => + { + b.OwnsMany("GozareshgirProgramManager.Domain.RoleUserAgg.RoleUser", "RoleUser", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.Property("UserId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("UserId"); + + b1.ToTable("RoleUsers", (string)null); + + b1.WithOwner("User") + .HasForeignKey("UserId"); + + b1.Navigation("User"); + }); + + b.Navigation("RoleUser"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.UserAgg.Entities.UserRefreshToken", b => + { + b.HasOne("GozareshgirProgramManager.Domain.UserAgg.Entities.User", "User") + .WithMany("RefreshTokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b => + { + b.Navigation("PhaseSections"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", b => + { + b.Navigation("Phases"); + + b.Navigation("ProjectSections"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b => + { + b.Navigation("Activities"); + + b.Navigation("AdditionalTimes"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.UserAgg.Entities.User", b => + { + b.Navigation("RefreshTokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/20260122100032_Add time Request and Task section revision.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/20260122100032_Add time Request and Task section revision.cs new file mode 100644 index 00000000..0a12abce --- /dev/null +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/20260122100032_Add time Request and Task section revision.cs @@ -0,0 +1,121 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GozareshgirProgramManager.Infrastructure.Migrations +{ + /// + public partial class AddtimeRequestandTasksectionrevision : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Type", + table: "TaskSectionAdditionalTimes", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateTable( + name: "TaskSectionRevisions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TaskSectionId = table.Column(type: "uniqueidentifier", nullable: false), + Status = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Message = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + CreatedByUserId = table.Column(type: "bigint", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskSectionRevisions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TaskSectionTimeRequests", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TaskSectionId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "bigint", nullable: false), + Description = table.Column(type: "nvarchar(1200)", maxLength: 1200, nullable: false), + RequestedTime = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + RequestType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + RequestStatus = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskSectionTimeRequests", x => x.Id); + table.ForeignKey( + name: "FK_TaskSectionTimeRequests_TaskSections_TaskSectionId", + column: x => x.TaskSectionId, + principalTable: "TaskSections", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TaskRevisionFile", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + FileId = table.Column(type: "uniqueidentifier", nullable: false), + TaskSectionRevisionId = table.Column(type: "uniqueidentifier", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskRevisionFile", x => x.Id); + table.ForeignKey( + name: "FK_TaskRevisionFile_TaskSectionRevisions_TaskSectionRevisionId", + column: x => x.TaskSectionRevisionId, + principalTable: "TaskSectionRevisions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TaskRevisionFile_UploadedFiles_FileId", + column: x => x.FileId, + principalTable: "UploadedFiles", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_TaskRevisionFile_FileId", + table: "TaskRevisionFile", + column: "FileId"); + + migrationBuilder.CreateIndex( + name: "IX_TaskRevisionFile_TaskSectionRevisionId", + table: "TaskRevisionFile", + column: "TaskSectionRevisionId"); + + migrationBuilder.CreateIndex( + name: "IX_TaskSectionTimeRequests_TaskSectionId", + table: "TaskSectionTimeRequests", + column: "TaskSectionId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TaskRevisionFile"); + + migrationBuilder.DropTable( + name: "TaskSectionTimeRequests"); + + migrationBuilder.DropTable( + name: "TaskSectionRevisions"); + + migrationBuilder.DropColumn( + name: "Type", + table: "TaskSectionAdditionalTimes"); + } + } +} diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 20d42131..95e939be 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -254,49 +254,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("PhaseSections", (string)null); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreationDate") - .HasColumnType("datetime2"); - - b.Property("Description") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("EndDate") - .HasColumnType("datetime2"); - - b.Property("HasAssignmentOverride") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PlannedEndDate") - .HasColumnType("datetime2"); - - b.Property("PlannedStartDate") - .HasColumnType("datetime2"); - - b.Property("StartDate") - .HasColumnType("datetime2"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Projects", (string)null); - }); - - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -348,7 +306,49 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("ProjectPhases", (string)null); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectSection", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("HasAssignmentOverride") + .HasColumnType("bit"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("PlannedEndDate") + .HasColumnType("datetime2"); + + b.Property("PlannedStartDate") + .HasColumnType("datetime2"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Projects", (string)null); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.ProjectSection", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -374,7 +374,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("ProjectSections", (string)null); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -433,7 +433,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("ProjectTasks", (string)null); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -476,7 +476,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("TaskSections", (string)null); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionActivity", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionActivity", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -514,7 +514,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("TaskSectionActivities", (string)null); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionAdditionalTime", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionAdditionalTime", b => { b.Property("Id") .HasColumnType("uniqueidentifier"); @@ -540,6 +540,11 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Property("TaskSectionId") .HasColumnType("uniqueidentifier"); + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.HasKey("Id"); b.HasIndex("TaskSectionId"); @@ -547,6 +552,76 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.ToTable("TaskSectionAdditionalTimes", (string)null); }); + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedByUserId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TaskSectionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.ToTable("TaskSectionRevisions"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionTimeRequest", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1200) + .HasColumnType("nvarchar(1200)"); + + b.Property("RequestStatus") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequestedTime") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskSectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("TaskSectionId"); + + b.ToTable("TaskSectionTimeRequests"); + }); + modelBuilder.Entity("GozareshgirProgramManager.Domain.RoleAgg.Entities.Role", b => { b.Property("Id") @@ -810,9 +885,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("Skill"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b => { - b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", "Project") + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", "Project") .WithMany("Phases") .HasForeignKey("ProjectId") .OnDelete(DeleteBehavior.Cascade) @@ -821,9 +896,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("Project"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectSection", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.ProjectSection", b => { - b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", "Project") + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", "Project") .WithMany("ProjectSections") .HasForeignKey("ProjectId") .OnDelete(DeleteBehavior.Cascade) @@ -839,9 +914,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("Skill"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b => { - b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", "Phase") + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", "Phase") .WithMany("Tasks") .HasForeignKey("PhaseId") .OnDelete(DeleteBehavior.Cascade) @@ -850,7 +925,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("Phase"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b => { b.HasOne("GozareshgirProgramManager.Domain.SkillAgg.Entities.Skill", "Skill") .WithMany("Sections") @@ -858,7 +933,7 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", "Task") + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", "Task") .WithMany("Sections") .HasForeignKey("TaskId") .OnDelete(DeleteBehavior.Cascade) @@ -869,9 +944,9 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("Task"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionActivity", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionActivity", b => { - b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", "Section") + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", "Section") .WithMany("Activities") .HasForeignKey("SectionId") .OnDelete(DeleteBehavior.Cascade) @@ -880,13 +955,61 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("Section"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSectionAdditionalTime", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionAdditionalTime", b => { - b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", null) + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", null) .WithMany("AdditionalTimes") .HasForeignKey("TaskSectionId"); }); + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionRevision", b => + { + b.OwnsMany("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskRevisionFile", "Files", b1 => + { + b1.Property("Id") + .HasColumnType("uniqueidentifier"); + + b1.Property("CreationDate") + .HasColumnType("datetime2"); + + b1.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b1.Property("TaskSectionRevisionId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("FileId"); + + b1.HasIndex("TaskSectionRevisionId"); + + b1.ToTable("TaskRevisionFile"); + + b1.HasOne("GozareshgirProgramManager.Domain.FileManagementAgg.Entities.UploadedFile", null) + .WithMany() + .HasForeignKey("FileId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b1.WithOwner() + .HasForeignKey("TaskSectionRevisionId"); + }); + + b.Navigation("Files"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSectionTimeRequest", b => + { + b.HasOne("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", "TaskSection") + .WithMany() + .HasForeignKey("TaskSectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskSection"); + }); + modelBuilder.Entity("GozareshgirProgramManager.Domain.RoleAgg.Entities.Role", b => { b.OwnsMany("GozareshgirProgramManager.Domain.PermissionAgg.Entities.Permission", "Permissions", b1 => @@ -1031,26 +1154,26 @@ namespace GozareshgirProgramManager.Infrastructure.Migrations b.Navigation("User"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project", b => - { - b.Navigation("Phases"); - - b.Navigation("ProjectSections"); - }); - - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectPhase", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase.ProjectPhase", b => { b.Navigation("PhaseSections"); b.Navigation("Tasks"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.ProjectTask", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project.Project", b => + { + b.Navigation("Phases"); + + b.Navigation("ProjectSections"); + }); + + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.ProjectTask", b => { b.Navigation("Sections"); }); - modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.TaskSection", b => + modelBuilder.Entity("GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection.TaskSection", b => { b.Navigation("Activities"); diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Context/ProgramManagerDbContext.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Context/ProgramManagerDbContext.cs index dbf13a07..0c2f4875 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Context/ProgramManagerDbContext.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Context/ProgramManagerDbContext.cs @@ -5,6 +5,10 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Domain.CustomerAgg; using GozareshgirProgramManager.Domain.FileManagementAgg.Entities; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.RoleAgg.Entities; using GozareshgirProgramManager.Domain.RoleUserAgg; using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Entities; @@ -50,6 +54,12 @@ public class ProgramManagerDbContext : DbContext, IProgramManagerDbContext // Task Chat public DbSet TaskChatMessages { get; set; } = null!; + //Task Section Time Request + public DbSet TaskSectionTimeRequests { get; set; } + + // Task Section Revision + public DbSet TaskSectionRevisions { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(typeof(ProgramManagerDbContext).Assembly); diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/AdditionalTimeMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/AdditionalTimeMapping.cs index 6c73bc87..9dc11054 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/AdditionalTimeMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/AdditionalTimeMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Infrastructure.Persistence._Common; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/PhaseSectionMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/PhaseSectionMapping.cs index 1b4a829f..18dc0a21 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/PhaseSectionMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/PhaseSectionMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectMapping.cs index 69a79750..ad127eff 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectPhaseMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectPhaseMapping.cs index 01a43077..b499f798 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectPhaseMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectPhaseMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectSectionMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectSectionMapping.cs index 454ab86d..fb50461b 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectSectionMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectSectionMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectTaskMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectTaskMapping.cs index 737d04e7..20ed29cd 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectTaskMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/ProjectTaskMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Infrastructure.Persistence._Common; using Microsoft.EntityFrameworkCore; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionActivityMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionActivityMapping.cs index 84f4227e..73356cbc 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionActivityMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionActivityMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionAdditionalTimeMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionAdditionalTimeMapping.cs index e6789d94..30dc130c 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionAdditionalTimeMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionAdditionalTimeMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Infrastructure.Persistence._Common; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -33,6 +34,9 @@ public class TaskSectionAdditionalTimeMapping : IEntityTypeConfiguration at.CreationDate) .IsRequired(); + builder.Property(x=>x.Type) + .HasConversion() + .HasMaxLength(50); // Ignore domain events builder.Ignore(at => at.DomainEvents); } diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionMapping.cs index 836580f0..ed6acc81 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionMapping.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionMapping.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Infrastructure.Persistence._Common; using Microsoft.EntityFrameworkCore; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionRevisionMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionRevisionMapping.cs new file mode 100644 index 00000000..25a796ad --- /dev/null +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionRevisionMapping.cs @@ -0,0 +1,34 @@ +using GozareshgirProgramManager.Domain.FileManagementAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings; + +public class TaskSectionRevisionMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(x => x.Id); + + builder.Property(x => x.Id) + .ValueGeneratedNever(); + + builder.Property(x => x.Status).HasConversion() + .HasMaxLength(50); + + builder.Property(x => x.Message).HasMaxLength(500); + + builder.OwnsMany(x => x.Files, file => + { + file.HasKey(x => x.Id); + file.Property(x => x.Id).ValueGeneratedNever(); + + file.HasOne() + .WithMany() + .HasForeignKey(x => x.FileId) + .IsRequired() + .OnDelete(DeleteBehavior.Restrict); + }); + } +} \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionTimeRequestMapping.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionTimeRequestMapping.cs new file mode 100644 index 00000000..6e3e6311 --- /dev/null +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Mappings/TaskSectionTimeRequestMapping.cs @@ -0,0 +1,33 @@ +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Infrastructure.Persistence._Common; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace GozareshgirProgramManager.Infrastructure.Persistence.Mappings; + +public class TaskSectionTimeRequestMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(x => x.Id); + + builder.Property(x => x.Id) + .ValueGeneratedNever(); + + builder.Property(x => x.RequestStatus). + HasConversion().HasMaxLength(50); + + builder.Property(x=>x.RequestType). + HasConversion().HasMaxLength(50); + + builder.Property(x => x.RequestedTime) + .HasTimeSpanConversion(); + + builder.Property(x=>x.Description) + .HasMaxLength(1200); + + builder.HasOne(x=>x.TaskSection) + .WithMany().HasForeignKey(x=>x.TaskSectionId); + + } +} \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/PhaseSectionRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/PhaseSectionRepository.cs index c582dffd..b3cb95dd 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/PhaseSectionRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/PhaseSectionRepository.cs @@ -1,6 +1,7 @@ using GozareshgirProgramManager.Infrastructure.Persistence._Common; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Infrastructure.Persistence.Context; namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectPhaseRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectPhaseRepository.cs index f00d4512..65f93b9b 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectPhaseRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectPhaseRepository.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Phase; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence._Common; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectRepository.cs index 21afca93..08a47ba4 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectRepository.cs @@ -1,5 +1,6 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence._Common; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectSectionRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectSectionRepository.cs index d2b115db..d1c9626e 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectSectionRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectSectionRepository.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Project; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence._Common; using GozareshgirProgramManager.Infrastructure.Persistence.Context; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectTaskRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectTaskRepository.cs index cbaa79fe..a56d8fbe 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectTaskRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/ProjectTaskRepository.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence._Common; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskChat/TaskChatMessageRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskChatMessageRepository.cs similarity index 100% rename from ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskChat/TaskChatMessageRepository.cs rename to ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskChatMessageRepository.cs diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionActivityRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionActivityRepository.cs index 4ae98bf7..c3ccfc05 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionActivityRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionActivityRepository.cs @@ -1,6 +1,7 @@ using GozareshgirProgramManager.Application.Modules.Projects.DTOs; using GozareshgirProgramManager.Application.Modules.Projects.Extensions; using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence._Common; using GozareshgirProgramManager.Infrastructure.Persistence.Context; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs index ce590dc7..d43a74c2 100644 --- a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRepository.cs @@ -1,4 +1,5 @@ using GozareshgirProgramManager.Domain.ProjectAgg.Entities; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence._Common; diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRevisionRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRevisionRepository.cs new file mode 100644 index 00000000..1241fcca --- /dev/null +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionRevisionRepository.cs @@ -0,0 +1,24 @@ +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; +using GozareshgirProgramManager.Infrastructure.Persistence._Common; +using GozareshgirProgramManager.Infrastructure.Persistence.Context; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories; + +public class TaskSectionRevisionRepository:RepositoryBase,ITaskSectionRevisionRepository +{ + private readonly ProgramManagerDbContext _programManagerDbContext; + public TaskSectionRevisionRepository(ProgramManagerDbContext programManagerDbContext) : base(programManagerDbContext) + { + _programManagerDbContext = programManagerDbContext; + } + + public async Task> GetByTaskSectionId(Guid requestTaskSectionId) + { + var res = await _programManagerDbContext.TaskSectionRevisions + .Where(x => requestTaskSectionId == x.TaskSectionId) + .ToListAsync(); + return res; + } +} \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionTimeRequestRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionTimeRequestRepository.cs new file mode 100644 index 00000000..48d6b181 --- /dev/null +++ b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/TaskSectionTimeRequestRepository.cs @@ -0,0 +1,16 @@ +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; +using GozareshgirProgramManager.Infrastructure.Persistence._Common; +using GozareshgirProgramManager.Infrastructure.Persistence.Context; +using Microsoft.EntityFrameworkCore; + +namespace GozareshgirProgramManager.Infrastructure.Persistence.Repositories; + +public class TaskSectionTimeRequestRepository:RepositoryBase,ITaskSectionTimeRequestRepository +{ + private readonly ProgramManagerDbContext _context; + public TaskSectionTimeRequestRepository(ProgramManagerDbContext context) : base(context) + { + _context = context; + } +} \ No newline at end of file diff --git a/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/FileManagement/UploadedFileRepository.cs b/ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/UploadedFileRepository.cs similarity index 100% rename from ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/FileManagement/UploadedFileRepository.cs rename to ProgramManager/src/Infrastructure/GozareshgirProgramManager.Infrastructure/Persistence/Repositories/UploadedFileRepository.cs diff --git a/ServiceHost/Areas/Admin/Controllers/ProgramManager/TaskSectionRevisionController.cs b/ServiceHost/Areas/Admin/Controllers/ProgramManager/TaskSectionRevisionController.cs new file mode 100644 index 00000000..39752fb7 --- /dev/null +++ b/ServiceHost/Areas/Admin/Controllers/ProgramManager/TaskSectionRevisionController.cs @@ -0,0 +1,33 @@ +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Commands.CreateTaskSectionRevision; +using GozareshgirProgramManager.Application.Modules.TaskSectionRevision.Queries.TaskRevisionsByTaskSectionId; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Admin.Controllers.ProgramManager; + +public class TaskSectionRevisionController:ProgramManagerBaseController +{ + private readonly IMediator _mediator; + + public TaskSectionRevisionController(IMediator mediator) + { + _mediator = mediator; + } + + [HttpPost] + public async Task> CreateTaskRevision([FromForm]CreateTaskSectionRevisionCommand command) + { + var res =await _mediator.Send(command); + return Ok(res); + } + + [HttpGet()] + public async Task>> GetRevisionsBySectionId( + TaskRevisionsByTaskSectionIdQuery query) + { + var res = await _mediator.Send(query); + return res; + } +} \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Controllers/ProgramManager/TimeRequestController.cs b/ServiceHost/Areas/Admin/Controllers/ProgramManager/TimeRequestController.cs new file mode 100644 index 00000000..e459f5ff --- /dev/null +++ b/ServiceHost/Areas/Admin/Controllers/ProgramManager/TimeRequestController.cs @@ -0,0 +1,70 @@ +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest; +using GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.CreateTimeRequest; +using GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Queries.CreateTimeRequestDetails; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities.Task.TaskSection; +using GozareshgirProgramManager.Domain.ProjectAgg.Enums; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Admin.Controllers.ProgramManager; + +public class TimeRequestController:ProgramManagerBaseController +{ + private readonly IMediator _mediator; + + public TimeRequestController(IMediator mediator) + { + _mediator = mediator; + } + + [HttpGet("Rejected")] + public async Task> GetCreateRejectedTimeRequest(Guid taskSectionId) + { + var command = new CreateTimeRequestDetailsQuery(taskSectionId); + var res = await _mediator.Send(command); + return res; + } + [HttpPost("Rejected")] + public async Task> CreateRejectedTimeRequest(CreateTimeRequest request) + { + var command = new CreateTimeRequestCommand(request.Hours, request.Minutes, request.Description, + TaskSectionTimeRequestType.RejectedTime,request.TaskSectionId); + var res = await _mediator.Send(command); + return res; + } + + [HttpPost("Initial")] + public async Task> CreateInitialTimeRequest(CreateTimeRequest request) + { + var command = new CreateTimeRequestCommand(request.Hours, request.Minutes, request.Description, + TaskSectionTimeRequestType.InitialTime,request.TaskSectionId); + var res = await _mediator.Send(command); + return res; + } + + [HttpPost("Additional")] + public async Task> CreateAdditionalTimeRequest(CreateTimeRequest request) + { + var command = new CreateTimeRequestCommand(request.Hours, request.Minutes, request.Description, + TaskSectionTimeRequestType.AdditionalTime,request.TaskSectionId); + var res = await _mediator.Send(command); + return res; + } + + [HttpPost("Accept")] + public async Task> AcceptTimeRequest(AcceptTimeRequestDto request) + { + var command = new AcceptTimeRequestCommand(request.TimeRequestId, request.SectionId, + request.TimeType, request.Hour, request.Minute); + var res = await _mediator.Send(command); + return res; + } +} + +public record CreateTimeRequest(int Hours, int Minutes, string Description,Guid TaskSectionId); + +public record AcceptTimeRequestDto(Guid TimeRequestId, Guid SectionId, + TaskSectionAdditionalTimeType TimeType, int Hour, int Minute); + diff --git a/ServiceHost/Areas/Admin/Controllers/ProgramManager/WorkflowController.cs b/ServiceHost/Areas/Admin/Controllers/ProgramManager/WorkflowController.cs new file mode 100644 index 00000000..6acda73d --- /dev/null +++ b/ServiceHost/Areas/Admin/Controllers/ProgramManager/WorkflowController.cs @@ -0,0 +1,32 @@ +using GozareshgirProgramManager.Application._Common.Models; +using GozareshgirProgramManager.Application.Modules.Workflows.Queries.WorkflowList; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Admin.Controllers.ProgramManager; + +public class WorkflowController:ProgramManagerBaseController +{ + private readonly IMediator _mediator; + + public WorkflowController(IMediator mediator) + { + _mediator = mediator; + } + + [HttpGet] + public async Task>> Get(WorkflowListQuery query) + { + var res = await _mediator.Send(query); + return res; + } + + [HttpGet("count")] + public async Task>> GetCount(WorkflowCountQuery query) + { + var res = await _mediator.Send(query); + return res; + } + +} \ No newline at end of file diff --git a/ServiceHost/Properties/launchSettings.json b/ServiceHost/Properties/launchSettings.json index 788962e4..7a417116 100644 --- a/ServiceHost/Properties/launchSettings.json +++ b/ServiceHost/Properties/launchSettings.json @@ -30,7 +30,7 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation", - "ASPNETCORE_URLS": "https://localhost:5004;http://localhost:5003" + "ASPNETCORE_URLS": "https://localhost:5004;http://localhost:5003;" }, "distributionName": "" }, @@ -44,7 +44,7 @@ "sqlDebugging": true, "dotnetRunMessages": "true", "nativeDebugging": true, - "applicationUrl": "https://localhost:5004;http://localhost:5003;", + "applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5006", "jsWebView2Debugging": false, "hotReloadEnabled": true } diff --git a/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs b/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs index d644bb5f..f884e41f 100644 --- a/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs +++ b/WorkFlow/Application/WorkFlow.Application/WorkFlowApplication.cs @@ -87,9 +87,7 @@ public class WorkFlowApplication : IWorkFlowApplication { return (await GetRollCallWorkFlowsCutByBgService(workshopId)).Count; } - - - + public async Task GetAllWorkFlowCount(long workshopId, long accountId) { var count = 0; @@ -434,7 +432,7 @@ public class WorkFlowApplication : IWorkFlowApplication var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now); List rollCalls = _rollCallACL.GetUndefinedRollCalls(workshopId, twoMonthsAgo, now.AddDays(-1).Date); var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now); - return rollCalls.Select(x => new DailyRollCallWorkFlowViewModel() + var res= rollCalls.Select(x => new DailyRollCallWorkFlowViewModel() { DateTime = x.DateTime, DateTimeFa = x.DateTimeFa, @@ -447,6 +445,8 @@ public class WorkFlowApplication : IWorkFlowApplication .ToList(), DayOfWeekFa = x.DateTime.DayOfWeek.DayOfWeeKToPersian() }).Where(y => y.RollCallWorkFlowPerDayViewModels != null && y.RollCallWorkFlowPerDayViewModels.Any()).OrderBy(x => x.DateTime).ToList(); + + return res; } /// @@ -757,7 +757,7 @@ public class WorkFlowApplication : IWorkFlowApplication var entites = _rollCallConfirmedWithoutLunchBreakRepository.GetByWorkshopId(workshopId, twoMonthsAgo, now).ToList(); - return employeeWithoutBreakTimeAndNotSliced.Where(x => !entites.Any(y => y.RollCallId == x.RollCallId)) + var res = employeeWithoutBreakTimeAndNotSliced.Where(x => !entites.Any(y => y.RollCallId == x.RollCallId)) .GroupBy(x => x.RollCallDate.Date).OrderBy(x => x.Key).Select(x => new DailyRollCallConfirmedWithoutLunchBreakViewModel { DateGr = x.Key.Date, @@ -770,6 +770,7 @@ public class WorkFlowApplication : IWorkFlowApplication RollCallId = y.RollCallId, }).ToList() }).ToList(); + return res; }