コード例 #1
0
ファイル: UserBLL.cs プロジェクト: ansarbek/thewall9-CMS
 public Task<IdentityResult> CreateAsync(RegisterBindingModel model)
 {
     var _AU = UserManager.FindByEmail(model.Email);
     if (_AU == null)
     {
         var user = new ApplicationUser()
         {
             UserName = model.Email,
             Email = model.Email,
             Name = model.Name,
         };
         return UserManager.CreateAsync(user, model.Password);
     }
     throw new RuleException("Ya existe un usuario con ese email");
 }
コード例 #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);
            }

            return Ok();
        }