Exemple #1
0
 public CreateCategoryValidator(AspProjekatContext context)
 {
     RuleFor(x => x.Name)
     .NotEmpty()
     .Must(name => !context.Categories.Any(g => g.Name == name))
     .WithMessage("Category name must be unique");
 }
Exemple #2
0
 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();
 }
Exemple #3
0
 public UploudImageValidator(AspProjekatContext context)
 {
     RuleFor(y => y.Path)
     .NotEmpty()
     .WithMessage("Path is required!");
     RuleFor(y => y.ProductId)
     .NotEmpty()
     .WithMessage("Id is required!");
 }
Exemple #4
0
        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.");
            });
        }
Exemple #5
0
 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!");
 }
Exemple #6
0
        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.");
        }
Exemple #8
0
        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;
 }
Exemple #11
0
 public EfChangeStatusOrderCommand(AspProjekatContext context)
 {
     _context = context;
 }
Exemple #12
0
 public JwtManager(AspProjekatContext context)
 {
     _context = context;
 }
Exemple #13
0
 public EfRegisterUserCommand(AspProjekatContext context, RegisterUserValidator validator, IEmailSender sender)
 {
     _context   = context;
     _validator = validator;
     _sender    = sender;
 }
Exemple #14
0
		public UploadController(AspProjekatContext context)
		{
			_context = context;
		}
Exemple #15
0
 public EfGetOrderQuery(AspProjekatContext context)
 {
     this.context = context;
 }
 public EfDeleteProductCommand(AspProjekatContext context)
 {
     this._context = context;
 }
Exemple #17
0
 public EfGetCategoryQuery(AspProjekatContext context)
 {
     _context = context;
 }
 public EfDeleteCategoryCommand(AspProjekatContext context)
 {
     this._context = context;
 }
Exemple #19
0
 public EfCreateBlogCommand(AspProjekatContext context, CreateBlogValidator validator, IApplicationActor actor)
 {
     _context   = context;
     _validator = validator;
     this.actor = actor;
 }
Exemple #20
0
 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;
 }
Exemple #27
0
 public EfGetOneCategoryQuery(AspProjekatContext context)
 {
     this.context = context;
 }
Exemple #28
0
 public EfCreateProductCommand(AspProjekatContext context, CreateProductValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Exemple #29
0
 public EfGetOneBlogQuery(AspProjekatContext context)
 {
     _context = context;
 }
Exemple #30
0
 public EfGetOneProductQuery(AspProjekatContext context)
 {
     this.context = context;
 }