Exemplo n.º 1
0
        public async Task <ValidationResult> ValidateNewResourceAsync(IResourceReadOnlyRepository resourceReadOnly)
        {
            NameNotEmptyRule();
            AmountEqualsGreaterThanZero();
            CanUseName(resourceReadOnly);

            this.ValidationResult = await ValidateAsync(this);

            return(ValidationResult);
        }
Exemplo n.º 2
0
        protected void CanUseName(IResourceReadOnlyRepository resourceReadOnly)
        {
            this.RuleFor(p => p.Name)
            .NotNull().WithMessage("O nome do recurso não pode ser vazio")
            .MustAsync(async(name, cancellationToken) =>
            {
                if (string.IsNullOrEmpty(name))
                {
                    return(true);
                }

                var sameNamesCount = await resourceReadOnly.CountByNameAsync(name);
                return(sameNamesCount == 0);
            }).WithMessage("Um recurso de mesmo nome já existe");
        }
Exemplo n.º 3
0
 public ResourceController(IResourceAppService resourceAppService,
                           IResourceReadOnlyRepository resourceReadOnlyRepository)
 {
     _resourceAppService         = resourceAppService;
     _resourceReadOnlyRepository = resourceReadOnlyRepository;
 }
Exemplo n.º 4
0
 public ResourceCommandHandler(IResourcePersistentRepository resourcePersistentRepository
                               , IResourceReadOnlyRepository resourceReadOnlyRepository)
 {
     _resourcePersistentRepository = resourcePersistentRepository;
     _resourceReadOnlyRepository   = resourceReadOnlyRepository;
 }
Exemplo n.º 5
0
 public ResourceAppService(IMediator mediator
                           , IResourceReadOnlyRepository resourceReadOnlyRepository)
 {
     this.mediator = mediator;
     _resourceReadOnlyRepository = resourceReadOnlyRepository;
 }