Ejemplo n.º 1
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(Ok("Deu erro"));
            }

            var novoPerfil = new ModelosDominio.Entidades.Perfil();

            var servicosDePerfis = new ServicosDePerfis(new PerfilRepositorio());
            var servicosIdentity = new ServicosIdentity(new IdentityRepositorio());

            novoPerfil.Nome    = model.Nome;
            novoPerfil.Email   = model.Email;
            novoPerfil.Id      = Guid.NewGuid();
            novoPerfil.IdConta = servicosIdentity.GetId(model.Email);

            servicosDePerfis.CriarPerfil(novoPerfil);

            return(Ok());
        }
Ejemplo n.º 2
0
        public string IdConta(string emaill)
        {
            var servicosIdentity = new ServicosIdentity(new IdentityRepositorio());

            return(servicosIdentity.GetId(emaill));
        }