annotate Agendas/trunk/src/Agendas.Repositories.NHibernate/EventoRepository.cs @ 140:3639803112c6

Refactoring de la relación entre Evento y Estado
author nelopauselli
date Fri, 29 Jul 2011 16:30:53 -0300
parents 462a78196d11
children a36a76bd6ec3
rev   line source
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
1 using System;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
2 using System.Collections.Generic;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
3 using AltNetHispano.Agendas.Domain;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
4 using AltNetHispano.Agendas.Domain.Repositories;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
5 using NHibernate;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
6
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
7 namespace AltNetHispano.Agendas.Repositories.NHibernate
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
8 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
9 public class EventoRepository : RepositoryBase<Evento>, IEventoRepository
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
10 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
11 public EventoRepository(ISessionFactory sessionFactory) : base(sessionFactory)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
12 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
13 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
14
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
15 public void Delete(Evento evento)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
16 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
17 Session.Delete(evento);
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
18 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
19
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
20 public Evento Get(Guid vanId)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
21 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
22 return Session.Get<Evento>(vanId);
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
23 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
24
118
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
25 public IList<Evento> GetActivos()
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
26 {
118
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
27 return
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
28 Session.QueryOver<Evento>().Where(
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
29 e =>
140
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 136
diff changeset
30 e.Estado != EventoPublicadoState.GetInstance()).List();
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
31 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
32
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
33 public Evento GetPropuestaByTitulo(string titulo)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
34 {
140
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 136
diff changeset
35 return Session.QueryOver<Evento>().Where(e => e.Estado == EventoPropuestoState.GetInstance() && e.Titulo==titulo).SingleOrDefault();
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
36 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
37
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
38 public void Update(Evento evento)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
39 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
40 //No es necesario implementarlo
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
41 }
118
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
42
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
43 public IList<Evento> GetByState(EventoState state)
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
44 {
140
3639803112c6 Refactoring de la relación entre Evento y Estado
nelopauselli
parents: 136
diff changeset
45 return Session.QueryOver<Evento>().Where(e => e.Estado == state).List();
118
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
46 }
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
47 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
48 }