Example #1
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            foreach (var argument in context.ActionArguments.Values.Where(v => v is RegisterRequest))
            {
                RegisterRequest command = argument as RegisterRequest;

                _userValidationService.RequireUniqueUsernameAndEmail(command.Username, command.Email, context.ModelState);
            }

            if (!context.ModelState.IsValid)
            {
                context.Result = new BadRequestObjectResult(context.ModelState);
            }
        }