add acceptTimeRequestCommandHandler- NotFinished

This commit is contained in:
2026-01-21 10:28:38 +03:30
parent d4694e7e1c
commit 88f54b6310
2 changed files with 50 additions and 14 deletions

View File

@@ -1,29 +1,41 @@
using FluentValidation;
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Domain.ProjectAgg.Entities;
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 AcceptTimeRequestCommandValidator : AbstractValidator<AcceptTimeRequestCommand>
public class AcceptTimeRequestCommandHandler:IBaseCommandHandler<AcceptTimeRequestCommand>
{
public AcceptTimeRequestCommandValidator()
private readonly ITaskSectionTimeRequestRepository _timeRequestRepository;
private readonly ITaskSectionRepository _taskSectionRepository;
public AcceptTimeRequestCommandHandler(ITaskSectionTimeRequestRepository timeRequestRepository, ITaskSectionRepository taskSectionRepository)
{
RuleFor(c => c.TimeRequestId)
.NotEmpty().WithMessage("شناسه درخواست نمیتواند خالی باشد");
_timeRequestRepository = timeRequestRepository;
_taskSectionRepository = taskSectionRepository;
}
RuleFor(c => c.SectionId)
.NotEmpty().WithMessage("شناسه بخش فرعی نمیتواند خالی باشد");
public async Task<OperationResult> Handle(AcceptTimeRequestCommand request, CancellationToken cancellationToken)
{
var timeRequest = await _timeRequestRepository.GetByIdAsync(request.TimeRequestId, cancellationToken);
if (timeRequest == null)
{
return OperationResult.NotFound("درخواست زمان شما یافت نشد");
}
RuleFor(c => c.TimeType)
.NotNull().WithMessage("نوع زمان درخواست شده نامعتبر است")
.IsInEnum();
var taskSection = await _taskSectionRepository.GetByIdAsync(request.SectionId, cancellationToken);
RuleFor(c => c.Hour)
.InclusiveBetween(0, 100).WithMessage("ساعت وارد شده میتواند بین 0 تا 100 باشد");
RuleFor(c => c.Minute)
.InclusiveBetween(0, 60).WithMessage("دقیقه وارد شده میتواند بین 0 تا 60 باشد");
if (taskSection == null)
{
return OperationResult.NotFound("بخش فرعی وارد شده نامعتبر است");
}
if (timeRequest.RequestType.)
{
}
}
}

View File

@@ -0,0 +1,24 @@
using FluentValidation;
namespace GozareshgirProgramManager.Application.Modules.TaskSectionTimeRequests.Commands.AcceptTimeRequest;
public class AcceptTimeRequestCommandValidator : AbstractValidator<AcceptTimeRequestCommand>
{
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 باشد");
}
}