public CreateCategoryValidator(AspProjekatContext context) { RuleFor(x => x.Name) .NotEmpty() .Must(name => !context.Categories.Any(g => g.Name == name)) .WithMessage("Category name must be unique"); }
public UpdateUserValidator(AspProjekatContext context) { RuleFor(x => x.FirstName).NotEmpty().NotNull(); RuleFor(x => x.LastName).NotEmpty().NotNull(); RuleFor(x => x.Username).NotEmpty().MinimumLength(4) .Must(x => !context.Users.Any(user => user.UserName == x)) .WithMessage("Username must be with atleast 4 characters and not empty and must be unique!"); RuleFor(x => x.Email).NotEmpty().EmailAddress(); }
public UploudImageValidator(AspProjekatContext context) { RuleFor(y => y.Path) .NotEmpty() .WithMessage("Path is required!"); RuleFor(y => y.ProductId) .NotEmpty() .WithMessage("Id is required!"); }
public CreateOrderInfoValidator(AspProjekatContext context) { this.context = context; RuleFor(x => x.ProductId) .Must(ProductExists) .WithMessage("Product with an id of {PropertyValue} doesn't exist.") .DependentRules(() => { RuleFor(x => x.Quantity) .GreaterThan(0) .WithMessage("Quantity must be greater than 0") .Must(QuantityDoesentExeedProductQuantity) .WithMessage("Defined quantity ({PropertyValue}) is unavailable."); }); }
public UpdateProductValidator(AspProjekatContext context) { RuleFor(y => y.Name) .NotEmpty() .WithMessage("Name is required!"); RuleFor(y => y.Description) .NotEmpty() .WithMessage("Description is required!"); //RuleFor(y => y.Slika) // .NotEmpty() // .WithMessage("Polje slika ne sme da bude prazno!"); RuleFor(y => y.Quantity) .NotEmpty() .WithMessage("Quantity is required!"); RuleFor(y => y.Price) .NotEmpty() .WithMessage("Price is required!"); }
public CreateProductValidator(AspProjekatContext context) { RuleFor(x => x.Name) .NotEmpty() .Must(name => !context.Categories.Any(g => g.Name == name)) .WithMessage("Product name must be unique"); RuleFor(x => x.Price).NotEmpty(); RuleFor(x => x.Description) .NotEmpty() .MinimumLength(6); RuleFor(x => x.Quantity).NotEmpty(); RuleFor(x => x.CategoryId) .NotEmpty() .Must(id => context.Categories.Any(x => x.Id == id)) .WithMessage("Category doesnt exist."); }
public RegisterUserValidator(AspProjekatContext context) { RuleFor(x => x.FirstName).NotEmpty(); RuleFor(x => x.LastName).NotEmpty(); RuleFor(x => x.Password) .NotEmpty() .MinimumLength(6); RuleFor(x => x.Username) .NotEmpty() .MinimumLength(4) .Must(x => !context.Users.Any(user => user.Username == x)) .WithMessage("Username is already taken."); RuleFor(x => x.Email) .NotEmpty() .EmailAddress(); RuleFor(x => x.RoleId) .NotEmpty() .Must(id => context.Roles.Any(x => x.Id == id)) .WithMessage("Role doesnt exist."); }
public CreateOrderValidator(AspProjekatContext context) { _context = context; RuleFor(x => x.OrderDate). GreaterThan(DateTime.Today) .WithMessage("Order date must be in future.") .LessThan(DateTime.Now.AddDays(30)) .WithMessage("Order date can't be more than 30 days from today."); RuleFor(x => x.Address) .NotEmpty() .WithMessage("Address is required."); RuleFor(x => x.Items) .NotEmpty() .WithMessage("There must be at least one order line.") .Must(i => i.Select(x => x.ProductId).Distinct().Count() == i.Count()) .WithMessage("Duplicate products are not allowed.") .DependentRules(() => { RuleForEach(x => x.Items).SetValidator (new CreateOrderInfoValidator(_context)); }); }
public EfGetOneRoleQuery(AspProjekatContext context) { this.context = context; }
public EfCreateCategoryCommand(AspProjekatContext context, CreateCategoryValidator validator) { _context = context; _validator = validator; }
public EfChangeStatusOrderCommand(AspProjekatContext context) { _context = context; }
public JwtManager(AspProjekatContext context) { _context = context; }
public EfRegisterUserCommand(AspProjekatContext context, RegisterUserValidator validator, IEmailSender sender) { _context = context; _validator = validator; _sender = sender; }
public UploadController(AspProjekatContext context) { _context = context; }
public EfGetOrderQuery(AspProjekatContext context) { this.context = context; }
public EfDeleteProductCommand(AspProjekatContext context) { this._context = context; }
public EfGetCategoryQuery(AspProjekatContext context) { _context = context; }
public EfDeleteCategoryCommand(AspProjekatContext context) { this._context = context; }
public EfCreateBlogCommand(AspProjekatContext context, CreateBlogValidator validator, IApplicationActor actor) { _context = context; _validator = validator; this.actor = actor; }
public ProductNameValidator(AspProjekatContext context) { RuleFor(y => y.Name) .Must(name => !context.Products.Any(k => k.Name == name)) .WithMessage("Name is not uniqe!"); }
public EfUpdateBlogCommand(AspProjekatContext context, UpdateBlogValidator validator) { _context = context; _validator = validator; }
public DatabaseUseCaseLogger(AspProjekatContext context) { _context = context; }
public EfGetOneUserQuery(AspProjekatContext context) { _context = context; }
public EfDeleteUserCommand(AspProjekatContext context, IApplicationActor actor) { _context = context; _actor = actor; }
public EfGetLogsQuery(AspProjekatContext context) { _context = context; }
public EfUpdateCategoryCommand(AspProjekatContext context) { _context = context; }
public EfGetOneCategoryQuery(AspProjekatContext context) { this.context = context; }
public EfCreateProductCommand(AspProjekatContext context, CreateProductValidator validator) { _context = context; _validator = validator; }
public EfGetOneBlogQuery(AspProjekatContext context) { _context = context; }
public EfGetOneProductQuery(AspProjekatContext context) { this.context = context; }