Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Domain/IdentityContext.cs @ 94:db4b1e2cae49
Cambio del nombre de la clase Ponente a Persona
Se agrega la clase Cuenta para identificar cada una de las cuentas con que se puede autenticar una persona
Alta Automatica de cuentas de twitter creando la persona
author | Nelo@Kenia.neluz.int |
---|---|
date | Sat, 04 Jun 2011 12:11:17 -0300 |
parents | 3059a5f8930f |
children | 0bca45e1e664 |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/IdentityContext.cs Sat Jun 04 00:07:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/IdentityContext.cs Sat Jun 04 12:11:17 2011 -0300 @@ -1,20 +1,28 @@ -using AltNetHispano.Agendas.Domain.Exceptions; +using System; +using AltNetHispano.Agendas.Domain.Exceptions; +using AltNetHispano.Agendas.Domain.Repositories; namespace AltNetHispano.Agendas.Domain { public class IdentityContext { private static ISeguridad _current; + private static IPersonaRepository _personaRepository; - public static ISeguridad Current + public static void Init(ISeguridad seguridad, IPersonaRepository personaRepository) { - private get + _current = seguridad; + _personaRepository = personaRepository; + } + + private static ISeguridad Current + { + get { if (_current == null) throw new IdentityContextNotConfiguredException(); return _current; } - set { _current = value; } } public static string GetUserName() @@ -24,5 +32,11 @@ throw new UsuarioNoAutenticadoException(); return username; } + + public static Persona GetUsuario() + { + var cuenta = _personaRepository.GetCuenta(IdentityProviderEnum.Twitter, GetUserName()); + return cuenta != null ? cuenta.Persona : null; + } } } \ No newline at end of file