view Agendas/trunk/src/Agendas.Twitter/Recordatorios.cs @ 217:c4c60e034103 deploy 2011-09-06

sugerencia de recordatorios
author nelopauselli
date Tue, 06 Sep 2011 18:09:43 -0300
parents
children e5959f3405e0
line wrap: on
line source

using System;
using System.Collections.Generic;
using AltNetHispano.Agendas.Domain;

namespace AltNetHispano.Agendas.Twitter
{
	public class Recordatorios
	{
		public Recordatorios(Evento evento)
		{
			if (!evento.FechaInicio.HasValue) throw new ArgumentNullException("evento");

			Items = new List<RecordatorioItem>();

			var fechaInicio = evento.FechaInicio.Value;

			Cabecera = "Recuerde agendar el evento en twuffer u otro servicio similar.";
			CabeceraLink = "http://twuffer.com/";

			for (int hora = 3; hora > 0; hora--)
			{
				var mensaje = TwitterStringHelper.TipoEvento(evento.Tipo) + " sobre " + evento.Titulo + " con " +
				              TwitterStringHelper.Ponente(evento.Ponente) + " inicia en [" + hora + "] hora" +
				              (hora > 1 ? "s" : string.Empty) + " " +
				              TwitterStringHelper.Hora(fechaInicio) + " http://snipr.com/virtualaltnet";

				var fechaRecordatorio = fechaInicio.AddHours(hora * -1);
				Items.Add(new RecordatorioItem(fechaRecordatorio, mensaje));
			}

			var mensaje15 = TwitterStringHelper.TipoEvento(evento.Tipo) + " sobre " + evento.Titulo + " con " +
						  TwitterStringHelper.Ponente(evento.Ponente) + " inicia en [15] minutos " +
						  TwitterStringHelper.Hora(fechaInicio) + " http://snipr.com/virtualaltnet";

			var fechaRecordatorio15 = fechaInicio.AddMinutes(-15);
			Items.Add(new RecordatorioItem(fechaRecordatorio15, mensaje15));
		}

		public string CabeceraLink { get; set; }

		public IList<RecordatorioItem> Items { get; set; }

		public string Cabecera { get; set; }
	}

	public class RecordatorioItem
	{
		public RecordatorioItem(DateTime momento, string mensaje)
		{
			Fecha = momento.ToString("dd/MM/yyyy");
			Hora = momento.ToString("HH:mm"); 
			Mensaje = mensaje;
		}

		public string Mensaje { get; set; }
		public string Hora { get; set; }
		public string Fecha { get; set; }
	}
}