Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs @ 143:2dbb15f4510f
Asociar Twitter a Persona existente
author | Nelo@Guinea.neluz.int |
---|---|
date | Mon, 01 Aug 2011 09:41:29 -0300 |
parents | 7a2eeb9e9bf9 |
children | a2b14da4902f |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs Mon Aug 01 00:28:04 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Services/PersonaService.cs Mon Aug 01 09:41:29 2011 -0300 @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using AltNetHispano.Agendas.Domain.Repositories; namespace AltNetHispano.Agendas.Domain.Services @@ -22,17 +21,23 @@ public bool CreateIfNotExist(IdentityProviderEnum identityProvider, string username, string nombre) { var cuenta = _personaRepository.GetCuenta(identityProvider, username); - if (cuenta==null) - { - var persona = IdentityContext.IsAuthenticated() ? IdentityContext.GetUsuario() : new Persona(nombre); - persona.AddCuenta(new Cuenta(identityProvider, username)); + if (cuenta == null) + { + Persona persona = null; + if (identityProvider == IdentityProviderEnum.Twitter) + persona = _personaRepository.GetByTwitter(username); + + if(persona==null) + persona = IdentityContext.IsAuthenticated() ? IdentityContext.GetUsuario() : new Persona(nombre); - if (identityProvider == IdentityProviderEnum.Twitter) - persona.Twitter = username; + persona.AddCuenta(new Cuenta(identityProvider, username)); - _personaRepository.Save(persona); - } - return true; + if (identityProvider == IdentityProviderEnum.Twitter) + persona.Twitter = username; + + _personaRepository.Save(persona); + } + return true; } public void AddCuenta(IdentityProviderEnum identityProvider, string username)