view 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
line wrap: on
line source

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>();

		#region IAgendaRepository Members

		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;
		}

		#endregion
	}
}