annotate Agendas/trunk/src/Agendas.Domain/Agenda.cs @ 57:3d9e6d56d903

Refactoring del track de cambios de un evento
author nelopauselli
date Mon, 16 May 2011 20:23:31 -0300
parents 3059a5f8930f
children 4a4e12e32256
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
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
45 Ponente ponente = GetPonente(ponenteNombre);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
46
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
47 if (evento.Titulo != titulo)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
48 evento.CambiarTitulo(titulo);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
49
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
50 if (evento.Fecha != fecha || evento.Ponente != ponente)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
51 evento.Actualizar(ponente, fecha);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
52
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
53 if (_publicador != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
54 _publicador.Publicar(evento);
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
55
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
56 return new Resultado(true);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
57 }
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
58
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
59 public Resultado ModificarPropuesta(Guid id, string titulo, string ponenteNombre)
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
60 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
61 return ModificarEvento(id, titulo, ponenteNombre, null);
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
62 }
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
63
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
64 public Resultado Proponer(string titulo, string ponenteNombre)
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
65 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
66 Ponente ponente = GetPonente(ponenteNombre);
57
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
67 var evento = Evento.Proponer(titulo, ponente);
21
43360bf09b1a unificando criterio de parámetros en Agenda
nelo@MTEySS.neluz.int
parents: 18
diff changeset
68
12
05996fa19e04 Unificamos Van y Cafe en Evento
nelo@MTEySS.neluz.int
parents: 11
diff changeset
69 if (string.IsNullOrWhiteSpace(evento.Titulo))
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
70 return new Resultado(false);
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
71
15
08b9e96132a5 Persistimos los eventos de la agenda
nelo@MTEySS.neluz.int
parents: 14
diff changeset
72 _eventosRepository.Save(evento);
26
71b02443450a UI de Propuestas de VANs
nelo@MTEySS.neluz.int
parents: 24
diff changeset
73 _ponenteRepository.Save(ponente);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
74
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
75 return new Resultado(true);
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
76 }
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
77
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
78 public Resultado Publicar(string titulo, string ponenteNombre, DateTime? fecha)
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
79 {
57
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
80 if (!fecha.HasValue)
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
81 return new Resultado(false);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
82 if (string.IsNullOrWhiteSpace(ponenteNombre))
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
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
85 Ponente ponente = GetPonente(ponenteNombre);
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
86
57
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
87 Evento evento = _eventosRepository.GetPropuestaByTitulo(titulo);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
88 if (evento == null)
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
89 evento = Evento.Publicar(titulo, ponente, fecha.Value);
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
90 else
3d9e6d56d903 Refactoring del track de cambios de un evento
nelopauselli
parents: 54
diff changeset
91 evento.Publicar(ponente, fecha);
38
3c5657d99727 Cambio de setters de las propiedades a private
nelo@MTEySS.neluz.int
parents: 37
diff changeset
92
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
93 if (_publicador != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
94 _publicador.Publicar(evento);
39
e548379cc314 track de cambios en evento
nelo@MTEySS.neluz.int
parents: 38
diff changeset
95
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
96 _eventosRepository.Save(evento);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
97 _ponenteRepository.Save(ponente);
53
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
98
d149bfea3892 Tratamos las validaciones como resultados y no como excepciones, dejamos las
nelopauselli
parents: 50
diff changeset
99 return new Resultado(true);
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
100 }
11
9d6b28a696d1 corrección en método que verifica la autenticación del usuario
nelo@MTEySS.neluz.int
parents: 9
diff changeset
101
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
102 public void RealizarEvento(Guid eventoId, string sintesis)
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
103 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
104 Evento evento = _eventosRepository.Get(eventoId);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
105 if (evento != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
106 evento.Realizado(sintesis);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
107 }
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
108
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
109 public void Recordar(Guid eventoId)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
110 {
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
111 Evento evento = _eventosRepository.Get(eventoId);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
112 if (_recordador != null)
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
113 _recordador.Recordar(evento);
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
114 }
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
115
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
116 public void RegistrarPonente(string nombre, string mail, string twitter, string blog)
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
117 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
118 var ponente = new Ponente(nombre, mail, twitter, blog);
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
119 _ponenteRepository.Save(ponente);
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
120 }
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
121
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
122 private Ponente GetPonente(string nombre)
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
123 {
54
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
124 Ponente ponente = _ponenteRepository.GetByNombre(nombre) ?? new Ponente(nombre);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
125 _ponenteRepository.Save(ponente);
3059a5f8930f Code cleanup
nelopauselli
parents: 53
diff changeset
126 return ponente;
24
41b283d27e3e Ponentes como entidad
nelo@MTEySS.neluz.int
parents: 21
diff changeset
127 }
14
ed6d842abf42 Modificar evento
nelo@MTEySS.neluz.int
parents: 12
diff changeset
128 }
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
129 }