Mercurial > altnet-hispano
comparison 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 |
comparison
equal
deleted
inserted
replaced
142:62dc9fb3a03e | 143:2dbb15f4510f |
---|---|
1 using System; | 1 using System.Linq; |
2 using System.Linq; | |
3 using AltNetHispano.Agendas.Domain.Repositories; | 2 using AltNetHispano.Agendas.Domain.Repositories; |
4 | 3 |
5 namespace AltNetHispano.Agendas.Domain.Services | 4 namespace AltNetHispano.Agendas.Domain.Services |
6 { | 5 { |
7 public class PersonaService | 6 public class PersonaService |
20 } | 19 } |
21 | 20 |
22 public bool CreateIfNotExist(IdentityProviderEnum identityProvider, string username, string nombre) | 21 public bool CreateIfNotExist(IdentityProviderEnum identityProvider, string username, string nombre) |
23 { | 22 { |
24 var cuenta = _personaRepository.GetCuenta(identityProvider, username); | 23 var cuenta = _personaRepository.GetCuenta(identityProvider, username); |
25 if (cuenta==null) | 24 if (cuenta == null) |
26 { | 25 { |
27 var persona = IdentityContext.IsAuthenticated() ? IdentityContext.GetUsuario() : new Persona(nombre); | 26 Persona persona = null; |
28 persona.AddCuenta(new Cuenta(identityProvider, username)); | 27 if (identityProvider == IdentityProviderEnum.Twitter) |
28 persona = _personaRepository.GetByTwitter(username); | |
29 | |
30 if(persona==null) | |
31 persona = IdentityContext.IsAuthenticated() ? IdentityContext.GetUsuario() : new Persona(nombre); | |
29 | 32 |
30 if (identityProvider == IdentityProviderEnum.Twitter) | 33 persona.AddCuenta(new Cuenta(identityProvider, username)); |
31 persona.Twitter = username; | |
32 | 34 |
33 _personaRepository.Save(persona); | 35 if (identityProvider == IdentityProviderEnum.Twitter) |
34 } | 36 persona.Twitter = username; |
35 return true; | 37 |
38 _personaRepository.Save(persona); | |
39 } | |
40 return true; | |
36 } | 41 } |
37 | 42 |
38 public void AddCuenta(IdentityProviderEnum identityProvider, string username) | 43 public void AddCuenta(IdentityProviderEnum identityProvider, string username) |
39 { | 44 { |
40 var persona = IdentityContext.GetUsuario(); | 45 var persona = IdentityContext.GetUsuario(); |