Ejemplo n.º 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");
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
 public UploudImageValidator(AspProjekatContext context)
 {
     RuleFor(y => y.Path)
     .NotEmpty()
     .WithMessage("Path is required!");
     RuleFor(y => y.ProductId)
     .NotEmpty()
     .WithMessage("Id is required!");
 }
Ejemplo n.º 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.");
            });
        }
Ejemplo n.º 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!");
 }
Ejemplo n.º 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.");
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 11
0
 public EfChangeStatusOrderCommand(AspProjekatContext context)
 {
     _context = context;
 }
Ejemplo n.º 12
0
 public JwtManager(AspProjekatContext context)
 {
     _context = context;
 }
Ejemplo n.º 13
0
 public EfRegisterUserCommand(AspProjekatContext context, RegisterUserValidator validator, IEmailSender sender)
 {
     _context   = context;
     _validator = validator;
     _sender    = sender;
 }
Ejemplo n.º 14
0
		public UploadController(AspProjekatContext context)
		{
			_context = context;
		}
Ejemplo n.º 15
0
 public EfGetOrderQuery(AspProjekatContext context)
 {
     this.context = context;
 }
 public EfDeleteProductCommand(AspProjekatContext context)
 {
     this._context = context;
 }
Ejemplo n.º 17
0
 public EfGetCategoryQuery(AspProjekatContext context)
 {
     _context = context;
 }
 public EfDeleteCategoryCommand(AspProjekatContext context)
 {
     this._context = context;
 }
Ejemplo n.º 19
0
 public EfCreateBlogCommand(AspProjekatContext context, CreateBlogValidator validator, IApplicationActor actor)
 {
     _context   = context;
     _validator = validator;
     this.actor = actor;
 }
Ejemplo n.º 20
0
 public ProductNameValidator(AspProjekatContext context)
 {
     RuleFor(y => y.Name)
     .Must(name => !context.Products.Any(k => k.Name == name))
     .WithMessage("Name is not uniqe!");
 }
Ejemplo n.º 21
0
 public EfUpdateBlogCommand(AspProjekatContext context, UpdateBlogValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Ejemplo n.º 22
0
 public DatabaseUseCaseLogger(AspProjekatContext context)
 {
     _context = context;
 }
Ejemplo n.º 23
0
		public EfGetOneUserQuery(AspProjekatContext context)
		{
			_context = context;
		}
Ejemplo n.º 24
0
 public EfDeleteUserCommand(AspProjekatContext context, IApplicationActor actor)
 {
     _context = context;
     _actor   = actor;
 }
Ejemplo n.º 25
0
 public EfGetLogsQuery(AspProjekatContext context)
 {
     _context = context;
 }
 public EfUpdateCategoryCommand(AspProjekatContext context)
 {
     _context = context;
 }
Ejemplo n.º 27
0
 public EfGetOneCategoryQuery(AspProjekatContext context)
 {
     this.context = context;
 }
Ejemplo n.º 28
0
 public EfCreateProductCommand(AspProjekatContext context, CreateProductValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Ejemplo n.º 29
0
 public EfGetOneBlogQuery(AspProjekatContext context)
 {
     _context = context;
 }
Ejemplo n.º 30
0
 public EfGetOneProductQuery(AspProjekatContext context)
 {
     this.context = context;
 }