view Agendas/trunk/src/Agendas.Repositories.NHibernate/PonenteRepository.cs @ 277:7439d7a5f8d0

Warning HTML: Cambiado ALT por TITLE.
author juanjose.montesdeocaarbos
date Tue, 20 Dec 2011 08:28:33 -0300
parents 50442a103281
children
line wrap: on
line source

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

namespace AltNetHispano.Agendas.Repositories.NHibernate
{
	public class PersonaRepository : RepositoryBase<Persona>, IPersonaRepository
	{
		public PersonaRepository(ISessionFactory sessionFactory) : base(sessionFactory)
		{
		}

		public IList<Persona> GetAll()
		{
            var personas = Session.QueryOver<Persona>().List();
            ((List<Persona>)personas).Sort((first, second) => first.Nombre.CompareTo(second.Nombre));

		    return personas;
		}

		public Persona GetByNombre(string ponenteNombre)
		{
			return Session.QueryOver<Persona>().Where(p => p.Nombre == ponenteNombre).SingleOrDefault();
		}

		public Cuenta GetCuenta(IdentityProviderEnum identityProvider, string username)
		{
			return
				Session.QueryOver<Cuenta>().Where(c => c.IdentityProvider == identityProvider && c.LogonName == username).
					SingleOrDefault();
		}

	    public Persona GetByTwitter(string username)
	    {
	        return Session.QueryOver<Persona>().Where(p => p.Twitter == username).SingleOrDefault();
	    }

	    public void Delete(Persona persona)
	    {
	        Session.Delete(persona);
	    }
	}
}