Mercurial > altnet-hispano
view Agendas/trunk/src/Agendas.Domain/IdentityContext.cs @ 126:6012f2becf97
Se agrega instalación de nuget package para el calendario de google.
author | alabra |
---|---|
date | Tue, 28 Jun 2011 23:35:22 -0400 |
parents | 7a2eeb9e9bf9 |
children | 1deccd6c3cb2 |
line wrap: on
line source
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 void Init(ISeguridad seguridad, IPersonaRepository personaRepository) { _current = seguridad; _personaRepository = personaRepository; } private static ISeguridad Current { get { if (_current == null) throw new IdentityContextNotConfiguredException(); return _current; } } public static string GetUserName() { return Current.GetUserName(); } public static bool IsAuthenticated() { return !string.IsNullOrWhiteSpace(GetUserName()); } public static Persona GetUsuario() { var userName = GetUserName(); if (string.IsNullOrWhiteSpace(userName)) throw new UsuarioNoAutenticadoException(); var identification = new Identification(userName); var cuenta = _personaRepository.GetCuenta(identification.IdentityProvider, identification.LogonName); return cuenta != null ? cuenta.Persona : null; } } }