コード例 #1
0
        public bool RegisterUserDetail(UserDetail model)
        {
            db.UserDetails.Add(model);
            db.SaveChanges();

            return true;
        }
コード例 #2
0
        public async Task<IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };

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

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }
            
            var userInfo = await UserManager.FindAsync(model.Email, model.Password);

            UserDetail userDetail = new UserDetail()
            {
                UserId = userInfo.Id,
                FirstName = model.FirstName,
                LastName = model.LastName
            };

            bool isRegisterUserDetail = _userRepository.RegisterUserDetail(userDetail);

            if (isRegisterUserDetail)
            {
                await SendLoginInformation(model);
                await SendEmailConfirmation(userInfo.Id, model.Email);
            }

            return Ok();
        }