public UpdateProjectParticipantCommandValidator(ITrackerDbContext context)
        {
            this.context = context;

            this.RuleFor(p => p.Id).NotEmpty();

            this.RuleFor(p => p.UserId).NotEmpty();

            this.RuleFor(v => v)
            .MustAsync((obj, domain) => this.IsOwner(obj.Id, obj.UserId, default))
            .WithMessage("Unable to update the participant, either you are not authorized or the Project has been removed");
        }
        public CreateProjectParticipantCommandValidator(ITrackerDbContext context)
        {
            this.context = context;

            this.RuleFor(p => p.UserId)
            .NotEmpty();

            this.RuleFor(p => p.ProjectId)
            .NotEmpty();

            this.RuleFor(v => v)
            .MustAsync((obj, domain) => this.IsProductOwner(obj.AddedBy, obj.ProjectId, default))
            .OverridePropertyName("OwnerId")
            .WithMessage("Unable to add participant, either you have no authorization or the Project has been removed");

            this.RuleFor(p => p)
            .MustAsync((obj, domain) => this.NotExist(obj.ProjectId, obj.UserId, default))
            .OverridePropertyName("UserId")
            .WithMessage("Participant has already been added to this project");
        }
        public CreateProjectCommandValidator(ITrackerDbContext context)
        {
            this.context = context;

            this.RuleFor(v => v.Name)
            .MaximumLength(500)
            .NotEmpty();

            this.RuleFor(v => v.OwnerId)
            .NotEmpty();

            // TODO: Move this validation logic.
            // Although this will work fine,
            // it is not a best practice to check for database existence in this validation layer,
            // instead, this validation should be done in the business layer.
            // Opinion needed.
            this.RuleFor(v => v.Key)
            .NotEmpty()
            .MinimumLength(3).WithMessage("Key must not less than 3 characters.")
            .MaximumLength(4).WithMessage("Key must not exceed 4 characters.")
            .MustAsync(this.UniqueKey).WithMessage("The specified 'Key' is already exists.");
        }
        public UpdateProjectCommandValidator(ITrackerDbContext context)
        {
            this.context = context;

            this.RuleFor(v => v.Name)
            .MaximumLength(500)
            .NotEmpty();

            this.RuleFor(v => v.OwnerId)
            .NotEmpty();

            // TODO: Move this validation logic.
            // Although this will work fine,
            // I don't think it is a good practice to check for database existence in this validation layer,
            // instead, this validation should be done in the business layer.
            this.When(v => v.IsDeleted, () =>
            {
                this.RuleFor(v => v)
                .MustAsync(this.IsTheOwner)
                .OverridePropertyName("OwnerId")
                .WithMessage("Unable to delete this Project! Only the owner can perform any delete operation.");
            });
        }
Пример #5
0
 public CreateProjectParticipantCommandHandler(ITrackerDbContext context)
 {
     this.context = context;
 }
Пример #6
0
 public GetParticipantsQueryHandler(ITrackerDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Пример #7
0
 public BaseHandler(ITrackerDbContext context) => this.Context = context;
Пример #8
0
 public GetIssuesQueryHandler(ITrackerDbContext context, IMapper mapper)
     : base(context, mapper)
 {
 }
Пример #9
0
 public UpdateIssueCommandHandler(ITrackerDbContext context, IMapper mapper)
     : base(context, mapper)
 {
 }
Пример #10
0
 public UpdateProjectCommandHandler(ITrackerDbContext context)
 {
     this.context = context;
 }
Пример #11
0
 public CreateIssueCommandHandler(ITrackerDbContext context)
 {
     this.context = context;
 }