view Agendas/trunk/src/Agendas.Blog/Impl/AgendarReunionPostWriter.cs @ 120:c3573defd18f

Agregado de Fecha, Usuario y Successful en TrackLog Modificacion de publicador de blog para usar TrackLog Agregado de TrackLog en el test de crud de eventos Fix en publicador de twitter para que no twitee si ya se encuentra en TrackLog pero con Successful en true
author Jorge@Jorge-PC
date Fri, 24 Jun 2011 21:18:21 -0300
parents 80c22175c9b5
children 2d02adb79322
line wrap: on
line source

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

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.Ponente.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.Fecha);
      return string.Format(CultureInfo.InvariantCulture, resourceName,
													 fecha, //Fecha y hora en GMT+0
													 track.Evento.Ponente.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;
		}
	}
}