Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Repositories.Memory/AgendaRepository.cs @ 2:c03560ae4762
Test de Crud para la agenda
author | nelopauselli |
---|---|
date | Sat, 22 Jan 2011 20:21:31 -0300 |
parents | |
children | 5f007e266509 |
comparison
equal
deleted
inserted
replaced
1:6bb4ab4c0611 | 2:c03560ae4762 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using AltNetHispano.Agendas.Domain; | |
4 using AltNetHispano.Agendas.Domain.Repositories; | |
5 | |
6 namespace Agendas.Repositories.Memory | |
7 { | |
8 public class AgendaRepository : IAgendaRepository | |
9 { | |
10 protected static readonly IDictionary<Guid, Agenda> Agendas = new Dictionary<Guid, Agenda>(); | |
11 | |
12 public void Save(Agenda agenda) | |
13 { | |
14 if (Guid.Empty.Equals(agenda.Id)) | |
15 { | |
16 agenda.Id = Guid.NewGuid(); | |
17 Agendas.Add(agenda.Id, agenda); | |
18 } | |
19 } | |
20 | |
21 public void Update(Agenda agenda) | |
22 { | |
23 //nada que hacer en este método para este repositorio | |
24 } | |
25 | |
26 public void Delete(Agenda agenda) | |
27 { | |
28 Agendas.Remove(agenda.Id); | |
29 } | |
30 | |
31 public Agenda Get(Guid agendaId) | |
32 { | |
33 Agenda agenda; | |
34 return Agendas.TryGetValue(agendaId, out agenda) ? agenda : null; | |
35 | |
36 } | |
37 } | |
38 } |