public ProductController(ShopContext dbcontext, IProductCount productCount, IDistributedCache distributedCache, ILogger <ProductController> logger) { _dbcontext = dbcontext; _productCount = productCount; _distributedCache = distributedCache; _logger = logger; }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { IProductCount service = (IProductCount)validationContext.GetService(typeof(IProductCount)); int current_number = service.GetProductNumber(); if (current_number >= max_number) { return(new ValidationResult($"There is {current_number} product in database, max number is: {max_number}")); } return(ValidationResult.Success); }
public ActionResultFilters(IProductCount productCount) { _productCount = productCount; }