Пример #1
0
        public CreateUserValidator(PhoTexBlogContext context)
        {
            _context = context;
            RuleFor(x => x.FirstName)
            .NotEmpty()
            .WithMessage("First name is required!")
            .MinimumLength(3)
            .WithMessage("First name must have at least 3 letters!");

            RuleFor(x => x.LastName)
            .NotEmpty()
            .WithMessage("Last name is required!")
            .MinimumLength(5)
            .WithMessage("Last name must have at least 5 letters!");

            RuleFor(x => x.Email)
            .NotEmpty()
            .WithMessage("Email is required!")
            .EmailAddress()
            .WithMessage("Invalid email format")
            .Must(email => UniqueEmail(email))
            .WithMessage("User already registered!");

            RuleFor(x => x.Password)
            .NotEmpty()
            .WithMessage("Password is required!")
            .MinimumLength(5)
            .WithMessage("Password must have at least 5 characters");
        }
        public CreatePostValidator(PhoTexBlogContext context)
        {
            _context = context;
            RuleFor(x => x.Title)
            .NotEmpty()
            .WithMessage("Title is required!")
            .MinimumLength(3)
            .WithMessage("Title must have at least 3 characters!");

            RuleFor(x => x.Content)
            .NotEmpty()
            .WithMessage("Content is required!")
            .MinimumLength(20)
            .WithMessage("Content must have at least 20 characters!");


            RuleFor(x => x.TopicId)
            .NotEmpty()
            .WithMessage("TopicId is required!")
            .Must(id => TopicExists(id))
            .WithMessage("Topic with that id doesn't exist!");

            RuleFor(x => x.UserId)
            .NotEmpty()
            .WithMessage("UserId is required!")
            .Must(id => UserExists(id))
            .WithMessage("User with that id doesn't exist!");
        }
Пример #3
0
 public CreateUseCaseValidator(PhoTexBlogContext context)
 {
     _context = context;
     RuleFor(x => x.Name)
     .NotEmpty().WithMessage("Name must not be empty!")
     .Must(name => NotExists(name)).WithMessage("UseCase already exists!");
 }
 public CreateTopicValidator(PhoTexBlogContext context)
 {
     _context = context;
     RuleFor(x => x.Name)
     .NotEmpty()
     .WithMessage("Name is required!")
     .Must(name => NotExists(name))
     .WithMessage("Topic with that name already exists!");
 }
        public CreateCommentValidator(PhoTexBlogContext context)
        {
            _context = context;
            RuleFor(x => x.CommentText)
            .NotEmpty().WithMessage("CommentText is required!")
            .MinimumLength(10).WithMessage("CommentText must have at least 10 characters!");

            RuleFor(x => x.PostId)
            .NotEmpty().WithMessage("PostId is required!")
            .Must(id => PostExist(id)).WithMessage("Post with that id doesn't exist!");
        }
Пример #6
0
        public UpdateUseCaseValidator(PhoTexBlogContext context)
        {
            _context = context;
            RuleFor(x => x.Id)
            .NotEmpty().WithMessage("Id is required!")
            .Must(id => Exist(id)).WithMessage("UseCase with that ID doesn't exist");

            RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Name is required!");

            RuleFor(x => x)
            .Must(x => BeUnique(x)).WithMessage("UseCase already exists!");
        }
Пример #7
0
        public CreateRatingValidator(PhoTexBlogContext context)
        {
            _context = context;
            RuleFor(x => x.Value)
            .NotEmpty().WithMessage("Value is required")
            .InclusiveBetween(1, 10).WithMessage("Value range is from 1 to 10");

            RuleFor(x => x.PostId)
            .NotEmpty().WithMessage("PostId is required!")
            .Must(id => PostExists(id)).WithMessage("Post with that Id doesn't exist!");
            RuleFor(x => x)
            .Must(x => UserNotRated(x))
            .WithMessage("You have already rated this post!");
        }
Пример #8
0
        public CreateUserUseCaseValidator(PhoTexBlogContext context)
        {
            _context = context;

            RuleFor(x => x.UseCaseId)
            .NotEmpty().WithMessage("UseCaseId is required!")
            .Must(id => UseCaseExists(id)).WithMessage("UseCase with that id doesn't exist");

            RuleFor(x => x.UserId)
            .NotEmpty().WithMessage("UserId is required!")
            .Must(id => UserExists(id)).WithMessage("User with that ID doesn't exist!");

            RuleFor(x => x)
            .Must(x => NotExist(x)).WithMessage("This user already has that privilege!");
        }
        public UpdateTopicValidator(PhoTexBlogContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .WithMessage("Name is required!");


            RuleFor(x => x.Id)
            .NotEmpty()
            .Must(id => exist(id))
            .WithMessage("Topic with that id doesn't exist!");


            RuleFor(x => x)
            .NotEmpty()
            .Must(x => BeUnique(x))
            .WithMessage($"Topic already exists!");
        }
Пример #10
0
        public UpdateUserValidator(PhoTexBlogContext context)
        {
            _context = context;

            RuleFor(x => x.Id)
            .NotEmpty()
            .WithMessage("Id is required!")
            .Must(id => Exist(id))
            .WithMessage("User with that ID doesn't exist!");

            RuleFor(x => x.FirstName)
            .NotEmpty()
            .WithMessage("First name is required!")
            .MinimumLength(3)
            .WithMessage("First name must have at least 3 letters!");

            RuleFor(x => x.LastName)
            .NotEmpty()
            .WithMessage("Last name is required!")
            .MinimumLength(5)
            .WithMessage("Last name must have at least 5 letters!");

            RuleFor(x => x.Email)
            .NotEmpty()
            .WithMessage("Email is required!")
            .EmailAddress()
            .WithMessage("Invalid email format");

            RuleFor(x => x)
            .Must(x => BeUnique(x))
            .WithMessage("Email already taken!");

            RuleFor(x => x.Password)
            .NotEmpty()
            .WithMessage("Password is required!")
            .MinimumLength(5)
            .WithMessage("Password must have at least 5 characters");
        }
Пример #11
0
 public EfGetCommentsQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #12
0
 public EfGetOneTopicQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #13
0
 public DBLogger(PhoTexBlogContext context)
 {
     _context = context;
 }
 public EfCreateCommentCommand(PhoTexBlogContext context, CreateCommentValidator validator, IApplicationActor actor)
 {
     _context   = context;
     _validator = validator;
     _actor     = actor;
 }
Пример #15
0
 public JwtManager(PhoTexBlogContext context, string issuer, string secretKey)
 {
     _context   = context;
     _issuer    = issuer;
     _secretKey = secretKey;
 }
Пример #16
0
 public EfGetOneRatingQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #17
0
 public EfGetOneUseCaseQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #18
0
 public EfGetUseCaseLogsQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #19
0
 public EfGetRatingsQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #20
0
 public EfGetOnePostQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #21
0
 public EfGetTopicsQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #22
0
 public EfCreatePostCommand(PhoTexBlogContext context, CreatePostValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Пример #23
0
 public EfCreateUserCommand(PhoTexBlogContext context, CreateUserValidator validator, IEmailSender sender)
 {
     _context   = context;
     _validator = validator;
     _sender    = sender;
 }
Пример #24
0
 public EfUpdatePostCommand(PhoTexBlogContext context, UpdatePostValidator validator, IApplicationActor actor)
 {
     _context   = context;
     _validator = validator;
     _actor     = actor;
 }
 public EFCreateTopicCommand(PhoTexBlogContext context, CreateTopicValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Пример #26
0
 public EfCreateUseCaseCommand(PhoTexBlogContext context, CreateUseCaseValidator validator)
 {
     _context   = context;
     _validator = validator;
 }
Пример #27
0
 public EfGetPostsQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
 public EfSoftDeleteTopicCommand(PhoTexBlogContext context)
 {
     _context = context;
 }
Пример #29
0
 public EfGetUsersQuery(PhoTexBlogContext context)
 {
     _context = context;
 }
 public EfSoftDeleteCommentCommand(PhoTexBlogContext context, IApplicationActor actor)
 {
     _context = context;
     _actor   = actor;
 }