예제 #1
0
 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();
        }