annotate Agendas/trunk/src/Agendas.Domain/Agenda.cs @ 61:cb3f7b47c1f0

Relación de Ponente a Eventos de los que es el ponente.
author nelopauselli
date Tue, 17 May 2011 01:27:03 -0300
parents 4a4e12e32256
children c7264bfc4b71
rev   line source
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
1 using System;
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
2 using System.Collections.Generic;
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
3 using AltNetHispano.Agendas.Domain.Exceptions;
15
08b9e96132a5 Persistimos los eventos de la agenda
nelo@MTEySS.neluz.int
parents: 14
diff changeset
4 using AltNetHispano.Agendas.Domain.Repositories;
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
5
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
6 namespace AltNetHispano.Agendas.Domain
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
7 {
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
8 public class Agenda
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
9 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
10 private readonly IEventoRepository _eventosRepository;
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
11 private readonly IPonenteRepository _ponenteRepository;
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
12 private readonly IPublicador _publicador;
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
13 private readonly IRecordador _recordador;
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
14
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
15 public Agenda(IPublicador publicador, IRecordador recordador, IEventoRepository eventosRepository,
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
16 IPonenteRepository ponenteRepository)
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
17 {
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
18 _publicador = publicador;
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
19 _ponenteRepository = ponenteRepository;
15
08b9e96132a5 Persistimos los eventos de la agenda
nelo@MTEySS.neluz.int
parents: 14
diff changeset
20 _eventosRepository = eventosRepository;
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
21 _recordador = recordador;
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
22 }
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
23
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
24 public Evento GetEvento(Guid id)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
25 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
26 return _eventosRepository.Get(id);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
27 }
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
28
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
29 public IList<Evento> GetEventosPropuestos()
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
30 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
31 return _eventosRepository.GetEventosSinFecha() ?? new List<Evento>();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
32 }
29
016b9b9b8d3a Cuando se publica una van con el mismo titulo que una propuesta, se utiliza esta
nelo@MTEySS.neluz.int
parents: 26
diff changeset
33
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
34 public IList<Evento> GetEventosPublicados()
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
35 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
36 return _eventosRepository.GetEventosConFecha() ?? new List<Evento>();
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
37 }
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
38
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
39 public Resultado ModificarEvento(Guid id, string titulo, string ponenteNombre, DateTime? fecha)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
40 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
41 Evento evento = _eventosRepository.Get(id);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
42 if (evento == null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
43 throw new EventoNotFoundException(id);
39
e548379cc314 track de cambios en evento
nelo@MTEySS.neluz.int
parents: 38
diff changeset
44
59
4a4e12e32256 Poder quitar un ponente de un evento propuesto
nelopauselli
parents: 57
diff changeset
45 Ponente ponente=null;
4a4e12e32256 Poder quitar un ponente de un evento propuesto
nelopauselli
parents: 57
diff changeset
46 if (!string.IsNullOrWhiteSpace(ponenteNombre))
4a4e12e32256 Poder quitar un ponente de un evento propuesto
nelopauselli
parents: 57
diff changeset
47 ponente = GetPonente(ponenteNombre);
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
48
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
49 if (evento.Titulo != titulo)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
50 evento.CambiarTitulo(titulo);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
51
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
52 if (evento.Fecha != fecha || evento.Ponente != ponente)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
53 evento.Actualizar(ponente, fecha);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
55 if (_publicador != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
56 _publicador.Publicar(evento);
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
57
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
58 return new Resultado(true);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
59 }
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
60
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
61 public Resultado ModificarPropuesta(Guid id, string titulo, string ponenteNombre)
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
62 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
63 return ModificarEvento(id, titulo, ponenteNombre, null);
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
64 }
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
65
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
66 public Resultado Proponer(string titulo, string ponenteNombre)
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
67 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
68 Ponente ponente = GetPonente(ponenteNombre);
57
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
69 var evento = Evento.Proponer(titulo, ponente);
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 18
diff changeset
70
12
05996fa19e04 Unificamos Van y Cafe en Evento
nelo@MTEySS.neluz.int
parents: 11
diff changeset
71 if (string.IsNullOrWhiteSpace(evento.Titulo))
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
72 return new Resultado(false);
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
73
15
08b9e96132a5 Persistimos los eventos de la agenda
nelo@MTEySS.neluz.int
parents: 14
diff changeset
74 _eventosRepository.Save(evento);
26
71b02443450a UI de Propuestas de VANs
nelo@MTEySS.neluz.int
parents: 24
diff changeset
75 _ponenteRepository.Save(ponente);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
76
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
77 return new Resultado(true);
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
78 }
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
79
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
80 public Resultado Publicar(string titulo, string ponenteNombre, DateTime? fecha)
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
81 {
57
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
82 if (!fecha.HasValue)
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
83 return new Resultado(false);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
84 if (string.IsNullOrWhiteSpace(ponenteNombre))
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
85 return new Resultado(false);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
86
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
87 Ponente ponente = GetPonente(ponenteNombre);
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
88
57
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
89 Evento evento = _eventosRepository.GetPropuestaByTitulo(titulo);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
90 if (evento == null)
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
91 evento = Evento.Publicar(titulo, ponente, fecha.Value);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
92 else
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
93 evento.Publicar(ponente, fecha);
38
3c5657d99727 Cambio de setters de las propiedades a private
nelo@MTEySS.neluz.int
parents: 37
diff changeset
94
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
95 if (_publicador != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
96 _publicador.Publicar(evento);
39
e548379cc314 track de cambios en evento
nelo@MTEySS.neluz.int
parents: 38
diff changeset
97
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
98 _eventosRepository.Save(evento);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
99 _ponenteRepository.Save(ponente);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
100
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
101 return new Resultado(true);
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
102 }
11
9d6b28a696d1 corrección en método que verifica la autenticación del usuario
nelo@MTEySS.neluz.int
parents: 9
diff changeset
103
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
104 public void RealizarEvento(Guid eventoId, string sintesis)
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
105 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
106 Evento evento = _eventosRepository.Get(eventoId);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
107 if (evento != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
108 evento.Realizado(sintesis);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
109 }
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
110
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
111 public void Recordar(Guid eventoId)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
112 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
113 Evento evento = _eventosRepository.Get(eventoId);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
114 if (_recordador != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
115 _recordador.Recordar(evento);
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
116 }
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
117
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
118 public void RegistrarPonente(string nombre, string mail, string twitter, string blog)
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
119 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
120 var ponente = new Ponente(nombre, mail, twitter, blog);
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
121 _ponenteRepository.Save(ponente);
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
122 }
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
123
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
124 private Ponente GetPonente(string nombre)
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
125 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
126 Ponente ponente = _ponenteRepository.GetByNombre(nombre) ?? new Ponente(nombre);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
127 _ponenteRepository.Save(ponente);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
128 return ponente;
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
129 }
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
130 }
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
131 }