annotate 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
rev   line source
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
1 using System;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
2 using System.Collections.Generic;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
3 using AltNetHispano.Agendas.Domain;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
4 using AltNetHispano.Agendas.Domain.Repositories;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
5
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
6 namespace Agendas.Repositories.Memory
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
7 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
8 public class AgendaRepository : IAgendaRepository
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
9 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
10 protected static readonly IDictionary<Guid, Agenda> Agendas = new Dictionary<Guid, Agenda>();
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
11
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
12 public void Save(Agenda agenda)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
13 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
14 if (Guid.Empty.Equals(agenda.Id))
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
15 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
16 agenda.Id = Guid.NewGuid();
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
17 Agendas.Add(agenda.Id, agenda);
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
18 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
19 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
20
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
21 public void Update(Agenda agenda)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
22 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
23 //nada que hacer en este método para este repositorio
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
24 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
25
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
26 public void Delete(Agenda agenda)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
27 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
28 Agendas.Remove(agenda.Id);
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
29 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
30
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
31 public Agenda Get(Guid agendaId)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
32 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
33 Agenda agenda;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
34 return Agendas.TryGetValue(agendaId, out agenda) ? agenda : null;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
35
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
36 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
37 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
38 }