public IAddProductJsonCommand(
     IJsonProductContext context,
     CreateProductJsonValidation productValidation)
 {
     _context           = context;
     _productValidation = productValidation;
 }
 public CreateProductJsonValidation(
     IJsonProductContext productContext,
     IJsonSupplierContext supplierContext,
     IJsonManufacturerContext manufacturerContext,
     IJsonCategoryContext categoryContext)
 {
     RuleFor(x => x.Name)
     .NotEmpty()
     .Must(name => !productContext.Read().Any(x => x.Name == name))
     .WithMessage("Name must be unique.");
     RuleFor(x => x.Category)
     .Must(category => categoryContext.Read().Any(x => x.Name == category))
     .WithMessage("Category must exist");
     RuleFor(x => x.Manufacturer)
     .Must(manufacturer => manufacturerContext.Read().Any(x => x.Name == manufacturer))
     .WithMessage("Manufacturer must exist");
     RuleFor(x => x.Supplier)
     .Must(supplier => supplierContext.Read().Any(x => x.Name == supplier))
     .WithMessage("Supplier must exist");
 }
 public UpdateProductJsonCommand(IJsonProductContext productContext, CreateProductValidation productValidation)
 {
     _productContext    = productContext;
     _productValidation = productValidation;
 }
 public GetSingleJsonProductQuery(IJsonProductContext productContext)
 {
     _productContext = productContext;
 }
Esempio n. 5
0
 public GetProductsJsonQuery(IJsonProductContext context)
 {
     _context = context;
 }