view Agendas/trunk/src/Agendas.Blog/Impl/AgendarReunionPostWriter.cs @ 230:e38d53a1ead9

Varios Ponentes en blog
author nelopauselli
date Wed, 28 Sep 2011 19:19:33 -0300
parents 2d02adb79322
children
line wrap: on
line source

using System;
using System.Globalization;
using Agendas.Blog.Exceptions;
using Agendas.Blog.Properties;
using AltNetHispano.Agendas.Domain;

namespace Agendas.Blog.Impl
{
	public class AgendarReunionPostWriter : PostWriter
	{
	  public AgendarReunionPostWriter(IPostWriterWebService postWriterWebService) : base(postWriterWebService)
	  {
	  }

    protected override string GetTitle(Track track)
    {
      string resourceName = getTitleResourceName(track);

    	return string.Format(CultureInfo.InvariantCulture, resourceName,
    	                     track.Evento.GetPonentesAsString(p => p.Nombre), //Nombre y apellido del ponente
							 track.Evento.Titulo); //Tema a tratar en la reunion
    }

	  private string getTitleResourceName(Track track)
	  {
	    string resourceName;
	    if (track.Evento.Tipo == TipoEvento.Van)
	      resourceName = Resources.VAN_Agendar_Title;
	    else if (track.Evento.Tipo == TipoEvento.Cafe)
	      resourceName = Resources.Cafe_Agendar_Title;
	    else
	      throw new TipoEventoNoSoportadoException(track.Evento.Tipo.ToString());

	    return resourceName;
	  }

	  protected override string GetBody(Track track)
		{
      string resourceName = getBodyResourceName(track);

			var fecha = getFechaFormateada(track.Evento.FechaInicio);
      return string.Format(CultureInfo.InvariantCulture, resourceName,
													 fecha, //Fecha y hora en GMT+0
													 track.Evento.GetPonentesAsString(p => p.Nombre), //Nombre y apellido del ponente
													 track.Evento.Titulo, //Tema a tratar en la reunion
													 getUrlInvitacion(track.Evento), //Url a la invitacion realizada por el ponente (por lo general es el thread en la lista de correo)
													 GetNombreUsuario(track) //Usuario que postea en el blog
				);
		}

    private string getBodyResourceName(Track track)
    {
      string resourceName;
      if (track.Evento.Tipo == TipoEvento.Van)
        resourceName = Resources.VAN_Agendar_Body;
      else if (track.Evento.Tipo == TipoEvento.Cafe)
        resourceName = Resources.Cafe_Agendar_Body;
      else
        throw new TipoEventoNoSoportadoException(track.Evento.Tipo.ToString());

      return resourceName;
    }

		private string getFechaFormateada(DateTime? fecha)
		{
			if (fecha == null)
				throw new ArgumentNullException("fecha");

			var fechaCast = (DateTime)fecha;
			var culture = CultureInfo.CreateSpecificCulture("es-ES");
			var result = fechaCast.ToString("D", culture) + " a las " +
										 fechaCast.ToString("t", culture) + " UTC/GMT";

			return result;
		}

		private string getUrlInvitacion(Evento evento)
		{
			if (!string.IsNullOrEmpty(evento.UrlInvitacion))
			{
				return string.Format(CultureInfo.InvariantCulture, Resources.Reunion_Agendar_Body_UrlListaCorreo,
														 evento.UrlInvitacion); 
			}

			return string.Empty;
		}
	}
}