Example #1
0
        public void Validate(ValidationContext context)
        {
            var value = (string)_accessor.GetValue(context.Target);

            if (_userService.ExistsByUsername(value))
            {
                var token = new ValidationKeys("UNIQUE_USER", "Username {0} is already in use.".ToFormat(FIELD.AsTemplateField()));
                var msg   = new NotificationMessage(token);
                msg.AddSubstitution(FIELD, value);

                context.Notification.RegisterMessage(_accessor, msg);
            }
        }
Example #2
0
            public void Validate(Accessor accessor, ValidationContext context)
            {
                var username    = context.GetFieldValue <string>(accessor);
                var userService = context.Service <IUserService>();

                if (userService.ExistsByUsername(username))
                {
                    var token = new ValidationKeys("Username {0} is already in use.".ToFormat(FIELD.AsTemplateField()));
                    var msg   = new NotificationMessage(token);
                    msg.AddSubstitution(FIELD, username);

                    context.Notification.RegisterMessage(accessor, msg);
                }
            }
	        public void Validate(Accessor accessor, ValidationContext context)
            {
                var username = context.GetFieldValue<string>(accessor);
                var userService = context.Service<IUserService>();
                
                if (userService.ExistsByUsername(username))
                {
                    var token = new ValidationKeys("Username {0} is already in use.".ToFormat(FIELD.AsTemplateField()));
                    var msg = new NotificationMessage(token);
                    msg.AddSubstitution(FIELD, username);

                    context.Notification.RegisterMessage(accessor, msg);
                }
            }