Пример #1
0
        public async Task <ActionResult> Register([FromBody] RegisterRequest request)
        {
            if (!request.Password.Equals(request.ConfirmPassword))
            {
                return(BadRequest());
            }

            var patchData = request.ToNewUser();

            try
            {
                var savedUser = await userService.CreateUser(patchData).ConfigureAwait(false);

                if (savedUser != null)
                {
                    return(Ok());
                }

                return(BadRequest());
            }
            catch (UserAlreadyExistsException)
            {
                throw new WWSSException("Username is not available", StatusCodes.Status400BadRequest);
            }
            catch (EmailAlreadyExistsException)
            {
                throw new WWSSException("Email is already used", StatusCodes.Status400BadRequest);
            }
        }