annotate Agendas/trunk/src/Agendas.Domain/Agenda.cs @ 4:49b572535156

proponer van publicar van propuesta comportamiento ante excepcion en publicador
author nelopauselli
date Tue, 08 Feb 2011 00:08:49 -0300
parents 5f007e266509
children 2912c1dd0e6b
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;
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
4
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
5 namespace AltNetHispano.Agendas.Domain
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
6 {
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
7 public class Agenda
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
8 {
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
9 private readonly IList<Evento> _eventos;
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
10 private readonly IPublicador _publicador;
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
11 private readonly IRecordador _recordador;
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
12
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
13 public Agenda(IPublicador publicador, IRecordador recordador)
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
14 {
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
15 _publicador = publicador;
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
16 _recordador = recordador;
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents: 1
diff changeset
17 _eventos = new List<Evento>();
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
18 }
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
19
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
20 public Guid Id { get; set; }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
21
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
22 public IEnumerable<Evento> Eventos
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
23 {
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
24 get { return _eventos; }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
25 }
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
26
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
27 public void Publicar(Evento evento)
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
28 {
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
29 if (!evento.Fecha.HasValue)
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
30 throw new ValidationException();
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
31
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
32 if (_publicador != null)
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
33 _publicador.Publicar(evento);
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
34 _eventos.Add(evento);
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
35 }
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
36
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
37 public void Publicar(Van van)
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
38 {
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
39 if (string.IsNullOrWhiteSpace(van.Ponente))
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
40 throw new ValidationException();
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
41 Publicar(van as Evento);
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
42 }
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
43
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
44
1
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
45 public void Recordar(Evento evento)
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
46 {
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
47 if (_recordador != null)
6bb4ab4c0611 Tests de Crud para repositorio de Vans
nelopauselli
parents: 0
diff changeset
48 _recordador.Recordar(evento);
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
49 }
4
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
50
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
51 public void Proponer(Van van)
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
52 {
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
53 if (string.IsNullOrWhiteSpace(van.Titulo))
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
54 throw new ValidationException();
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
55 _eventos.Add(van);
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
56 }
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
57
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
58 public IList<Evento> GetEventosPropuestos()
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
59 {
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
60 return _eventos;
49b572535156 proponer van
nelopauselli
parents: 3
diff changeset
61 }
0
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
62 }
3f7dbb633b71 Test sobre la publicación de Eventos al registrarlos en la Agenda
nelopauselli
parents:
diff changeset
63 }