public async Task <bool> CreateUser(UserModel model) { try { return(await rep.CreateUser(model)); } catch (Exception e) { throw new ApplicationException($"Ha ocurrido un error {e.Message}"); } }
public async Task <IHttpActionResult> Register(Register model) { if (!ModelState.IsValid) { return(BadRequest()); } IdentityResult result = await repository.CreateUser(model.Email, model.Password); if (!result.Succeeded) { return(GetErrorResult(result)); } result = await repository.AssignRole(model.Email, model.Password, model.RoleType.ToString()); IdentityUser user = await repository.FindUser(model.Email, model.Password); return(GetErrorResult(result) ?? Ok(new { userId = user.Id })); }