Beispiel #1
0
        public AppUserRegisterValidator(IAppUserDBRepository repository)
        {
            this.Repository = repository;

            // Email Required
            this.RuleFor(x => x.NormalizedEmail)
            .NotEmpty();

            // Email has email address
            this.RuleFor(x => x.NormalizedEmail)
            .EmailAddress();

            // User Name Required
            this.RuleFor(x => x.UserName)
            .NotEmpty();

            // User Name minimum length
            this.RuleFor(x => x.UserName)
            .MinimumLength(3);

            //Email doesn't exists
            this.When(x => !string.IsNullOrWhiteSpace(x.NormalizedEmail), () =>
            {
                this.RuleFor(x => x.NormalizedEmail)
                .Must(email =>
                {
                    var result = this.Repository.ExistsByEmail(email);
                    return(result.IsSucceed && result.Bag);
                });
            });

            //UserName doesn't exists
            this.When(x => !string.IsNullOrWhiteSpace(x.UserName), () =>
            {
                this.RuleFor(x => x.UserName)
                .Must(userName =>
                {
                    var result = this.Repository.ExistsByUserName(userName);
                    return(result.IsSucceed && result.Bag);
                });
            });
        }
Beispiel #2
0
 public BaseSignalR(ICurrentUserService currentUserService, IDbContextScopeFactory dbContextScopeFactory, IAppUserDBRepository repository)
 {
     this.CurrentUserService    = currentUserService;
     this.DbContextScopeFactory = dbContextScopeFactory;
     this.Repository            = repository;
 }