Mercurial > altnet-hispano
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Repositories.Memory/AgendaRepository.cs Sat Jan 22 20:21:31 2011 -0300 @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Domain.Repositories; + +namespace Agendas.Repositories.Memory +{ + public class AgendaRepository : IAgendaRepository + { + protected static readonly IDictionary<Guid, Agenda> Agendas = new Dictionary<Guid, Agenda>(); + + public void Save(Agenda agenda) + { + if (Guid.Empty.Equals(agenda.Id)) + { + agenda.Id = Guid.NewGuid(); + Agendas.Add(agenda.Id, agenda); + } + } + + public void Update(Agenda agenda) + { + //nada que hacer en este método para este repositorio + } + + public void Delete(Agenda agenda) + { + Agendas.Remove(agenda.Id); + } + + public Agenda Get(Guid agendaId) + { + Agenda agenda; + return Agendas.TryGetValue(agendaId, out agenda) ? agenda : null; + + } + } +} \ No newline at end of file