コード例 #1
0
        public async Task <bool> CreateUser(UserRegister newUser)
        {
            bool success = false;

            try
            {
                AppUser user = await UserManager.FindByNameAsync(newUser.UserName);

                if (user == null)
                {
                    user             = newUser.Adapt <AppUser>();
                    user.CreatedDate = DateTime.Now;

                    IdentityResult result = await UserManager.CreateAsync(user, newUser.Password);

                    success = result.Succeeded;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(success);
        }