view Agendas/trunk/src/Agendas.Repositories.Memory/PonenteRepository.cs @ 154:2233039ac2eb

Unificando vistas
author Nelo@Guinea.neluz.int
date Wed, 03 Aug 2011 01:02:42 -0300
parents 2dbb15f4510f
children 50442a103281
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.Linq;
using AltNetHispano.Agendas.Domain;
using AltNetHispano.Agendas.Domain.Repositories;

namespace AltNetHispano.Agendas.Repositories.Memory
{
	public class PersonaRepository : RepositoryBase<Persona>, IPersonaRepository
	{
		public Persona GetByNombre(string nombre)
		{
			return Objects.Values.SingleOrDefault(p => p.Nombre == nombre);
		}

		public Cuenta GetCuenta(IdentityProviderEnum identityProvider, string username)
		{
			var cuentas = from p in Objects.Values
			             select p.Cuentas.SingleOrDefault(c => c.IdentityProvider == identityProvider && c.LogonName == username);

			return cuentas.Where(c => c != null).SingleOrDefault();
		}

	    public Persona GetByTwitter(string username)
	    {
	        return Objects.Values.SingleOrDefault(p => p.Twitter == username);
	    }

	    public IList<Persona> GetAll()
		{
			return Objects.Values.ToList();
		}

		public static void Clear()
		{
			Objects.Clear();
		}
	}
}