コード例 #1
0
        public IActionResult Put([BindRequired, FromBody] AltSourceNewUserDto input)
        {
            try
            {
                UserInputValidation.ValidateUsername(input.Username);
                UserInputValidation.ValidatePassword(input.Password);
                UserInputValidation.ValidateName(input.FirstName);
                UserInputValidation.ValidateName(input.LastName);
                UserInputValidation.ValidateAddress(input.Address);

                var encodedAddress = HtmlEncoder.Default.Encode(input.Address);

                // ReSharper disable once UnusedVariable
                var result = Users.CreateAltSourceUser(_userManager,
                                                       input.Username,
                                                       input.Password,
                                                       input.FirstName,
                                                       input.LastName,
                                                       encodedAddress,
                                                       false)
                             .Result;

                if (!result.Succeeded)
                {
                    return(BadRequest(result.CompileErrorMessage()));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }