public ImagesService(
     IValidationService validator,
     ICognitiveServicesDbContext context,
     IMapper mapper)
     : base(validator, context, mapper)
 {
 }
 public DeleteImageValidator(ICognitiveServicesDbContext context)
 {
     RuleSet("Phase 1", () =>
     {
         RuleFor(n => n.Id)
         .NotEmpty()
         .MustAsync(async(id, cancellation) => await context.Images.AnyAsync(n => n.Id == id.Value));
     });
 }
 public BaseService(
     IValidationService validator,
     ICognitiveServicesDbContext context,
     IMapper mapper)
 {
     _validator = validator;
     _context   = context;
     _mapper    = mapper;
 }
Ejemplo n.º 4
0
 public static IRuleBuilderOptions <TModel, TProperty> CategoriesAreValid <TModel, TProperty>(
     this IRuleBuilder <TModel, TProperty> ruleBuilder,
     ICognitiveServicesDbContext cognitiveServicesDbContext,
     IImageRecognitionClient imageRecognitionClient,
     string errorMessage = ErrorMessages.InvalidCategories)
     where TModel : UpsertImageDto
 {
     return(ruleBuilder.SetValidator(new CategoriesValidator <TModel>(cognitiveServicesDbContext, imageRecognitionClient, errorMessage)));
 }
 public CategoriesValidator(
     ICognitiveServicesDbContext context,
     IImageRecognitionClient imageRecognitionClient,
     string errorMessage)
     : base(errorMessage)
 {
     _context = context;
     _imageRecognitionClient = imageRecognitionClient;
 }
Ejemplo n.º 6
0
        public UpdateImageValidator(ICognitiveServicesDbContext context, IImageRecognitionClient imageRecognitionClient)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            RuleSet("Phase 1", () =>
            {
                RuleFor(n => n.Id)
                .MustAsync(async(id, cancellation) => await context.Images.AnyAsync(n => n.Id == id));
            });

            RuleSet("Phase 2", () =>
            {
                RuleFor(n => n.CategoryIds)
                .CategoriesAreValid(context, imageRecognitionClient);
            });
        }
        public ImageValidator(ICognitiveServicesDbContext context, IImageRecognitionClient imageRecognitionClient)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            RuleSet("Phase 1", () =>
            {
                RuleFor(n => n.CategoryIds)
                .NotEmpty();

                RuleFor(n => n.Content)
                .NotEmpty();
            });

            RuleSet("Phase 2", () =>
            {
                RuleFor(n => n)
                .CategoriesAreValid(context, imageRecognitionClient);
            });
        }