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..a27d2c20 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,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application.Modules.Projects.DTOs; +using GozareshgirProgramManager.Domain.ProjectAgg.Entities; using GozareshgirProgramManager.Domain.ProjectAgg.Enums; namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject; @@ -15,4 +16,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..9afa83d4 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 @@ -369,7 +369,7 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler +{ + 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/CreateTimeRequestValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestValidator.cs index 03d65b77..82484ad0 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestValidator.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/TaskSectionTimeRequests/Commands/CreateTimeRequest/CreateTimeRequestValidator.cs @@ -10,7 +10,7 @@ public class CreateTimeRequestValidator : AbstractValidator c.Minutes) - .InclusiveBetween(0, 60) + .InclusiveBetween(0, 59) .WithMessage("دقیقه وارد شده باید بین 0 تا 60 باشد"); RuleFor(x => x.RequestType) diff --git a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs index 83b86c23..3bb41ee6 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSection.cs @@ -61,12 +61,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/TaskSectionAdditionalTime.cs b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionAdditionalTime.cs index 657f76cc..d8f54456 100644 --- a/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionAdditionalTime.cs +++ b/ProgramManager/src/Domain/GozareshgirProgramManager.Domain/ProjectAgg/Entities/TaskSectionAdditionalTime.cs @@ -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, +}