public async Task <IActionResult> SignUp(SignUpFormDTO signUpForm)
        {
            User registeredUser = await _userManager.FindByNameAsync(signUpForm.UserName);

            if (registeredUser != null)
            {
                return(Ok(false));
            }

            User user = new User {
                Email = signUpForm.Email, UserName = signUpForm.UserName
            };

            var result = await _userManager.CreateAsync(user, signUpForm.Password);

            if (result.Succeeded)
            {
                await _userManager.AddToRoleAsync(user, "User");

                _serviceWrapper.Save();
                await _signInManager.SignInAsync(user, false);

                var roles = await _userManager.GetRolesAsync(user);

                return(Ok(new { user.UserName, user.Email, Role = roles.First() }));
            }

            else
            {
                return(Ok(false));
            }
        }
        public async Task <IActionResult> SignUp(SignUpFormDTO signUpForm)
        {
            User registeredUser = await _userManager.FindByEmailAsync(signUpForm.Email);

            if (registeredUser != null)
            {
                return(BadRequest("User is registered."));
            }

            User user = new User {
                Email = signUpForm.Email, UserName = signUpForm.UserName
            };
            await _userManager.AddToRoleAsync(user, "User");

            var result = await _userManager.CreateAsync(user, signUpForm.Password);

            if (result.Succeeded)
            {
                _serviceWrapper.Save();
                await _signInManager.SignInAsync(user, false);

                return(Ok("Account created"));
            }

            else
            {
                return(BadRequest("Incorrect login or password"));
            }
        }