annotate Agendas/trunk/src/Agendas.Repositories.Memory/AgendaRepository.cs @ 3:5f007e266509

code cleanup
author nelopauselli
date Sat, 22 Jan 2011 20:23:50 -0300
parents c03560ae4762
children 49b572535156
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
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
12 #region IAgendaRepository Members
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
13
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
14 public void Save(Agenda agenda)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
15 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
16 if (Guid.Empty.Equals(agenda.Id))
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
17 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
18 agenda.Id = Guid.NewGuid();
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
19 Agendas.Add(agenda.Id, agenda);
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
20 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
21 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
22
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
23 public void Update(Agenda agenda)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
24 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
25 //nada que hacer en este método para este repositorio
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
26 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
27
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
28 public void Delete(Agenda agenda)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
29 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
30 Agendas.Remove(agenda.Id);
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
31 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
32
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
33 public Agenda Get(Guid agendaId)
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
34 {
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
35 Agenda agenda;
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
36 return Agendas.TryGetValue(agendaId, out agenda) ? agenda : null;
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
37 }
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
38
3
5f007e266509 code cleanup
nelopauselli
parents: 2
diff changeset
39 #endregion
2
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
40 }
c03560ae4762 Test de Crud para la agenda
nelopauselli
parents:
diff changeset
41 }