Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Domain/EventoPropuestoState.cs @ 140:3639803112c6
Refactoring de la relación entre Evento y Estado
author | nelopauselli |
---|---|
date | Fri, 29 Jul 2011 16:30:53 -0300 |
parents | 6f1041301797 |
children | 3ca9fb66d397 |
comparison
equal
deleted
inserted
replaced
139:18e5a78186e4 | 140:3639803112c6 |
---|---|
1 using System; | 1 using System; |
2 using AltNetHispano.Agendas.Domain.Exceptions; | 2 using AltNetHispano.Agendas.Domain.Exceptions; |
3 | 3 |
4 namespace AltNetHispano.Agendas.Domain | 4 namespace AltNetHispano.Agendas.Domain |
5 { | 5 { |
6 public class EventoPropuestoState : EventoState | 6 public class EventoPropuestoState : EventoState |
7 { | 7 { |
8 private EventoPropuestoState() | 8 protected EventoPropuestoState() |
9 { | 9 { |
10 } | 10 } |
11 | 11 |
12 private static readonly EventoState _instance = new EventoPropuestoState(); | 12 private static readonly EventoState _instance = new EventoPropuestoState(); |
13 public static EventoState GetInstance() | 13 public static EventoState GetInstance() |
14 { | 14 { |
15 return _instance; | 15 return _instance; |
16 } | 16 } |
17 | 17 |
18 private const string Descripcion = "Propuesto"; | 18 public override void Promover(Evento evento, Accion accion) |
19 { | |
20 switch (accion) | |
21 { | |
22 case Accion.Agendar: | |
23 evento.Estado = EventoAgendadoState.GetInstance(); | |
24 evento.AddTrack(new Track(evento, Accion.Agendar)); | |
25 break; | |
26 case Accion.Descartar: | |
27 evento.Estado = EventoDescartadoState.GetInstance(); | |
28 evento.AddTrack(new Track(evento, Accion.Descartar)); | |
29 break; | |
30 default: | |
31 throw new AccionNoSoportadaException(this.GetType(), accion); | |
32 } | |
33 } | |
19 | 34 |
20 public override void Promover(Evento evento, Accion accion) | 35 public override string Descripcion |
21 { | 36 { |
22 switch (accion) | 37 get { return "Propuesto"; } |
23 { | 38 } |
24 case Accion.Agendar: | |
25 evento.SetEstado(EventoAgendadoState.GetInstance()); | |
26 evento.AddTrack(new Track(evento, Accion.Agendar)); | |
27 break; | |
28 case Accion.Descartar: | |
29 evento.SetEstado(EventoDescartadoState.GetInstance()); | |
30 evento.AddTrack(new Track(evento, Accion.Descartar)); | |
31 break; | |
32 default: | |
33 throw new AccionNoSoportadaException(this.GetType(), accion); | |
34 } | |
35 } | |
36 | 39 |
37 public override string GetDescripcion() | 40 public override bool PuedePromover(Accion accion) |
38 { | 41 { |
39 return Descripcion; | 42 return accion == Accion.Agendar || accion == Accion.Descartar; |
40 } | 43 } |
41 | 44 } |
42 public override bool PuedePromover(Accion accion) | |
43 { | |
44 return accion == Accion.Agendar || accion == Accion.Descartar; | |
45 } | |
46 } | |
47 } | 45 } |