annotate Agendas/trunk/src/Agendas.Repositories.NHibernate/EventoRepository.cs @ 136:462a78196d11

Filtrado de eventos por estado
author nelopauselli
date Tue, 26 Jul 2011 14:33:49 -0300
parents b74734a1a755
children 3639803112c6
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 =>
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
30 e.Estado != EventoPublicadoState.GetInstance().GetDescripcion()).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 {
136
462a78196d11 Filtrado de eventos por estado
nelopauselli
parents: 118
diff changeset
35 return Session.QueryOver<Evento>().Where(e => e.Estado == EventoPropuestoState.GetInstance().GetDescripcion() && 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 {
b74734a1a755 Manejo de eventos por estado
Nelo@Kenia.neluz.int
parents: 63
diff changeset
45 return Session.QueryOver<Evento>().Where(e => e.Estado == state.GetDescripcion()).List();
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 }