view Agendas/trunk/src/Agendas.Web/DataProviders.cs @ 289:8b0c62c255cd

Se modifica DataAnnotationAndConventionModelMetadataProvider.cs para que lea Recursos en base al Assembly Fullname
author juanjose.montesdeocaarbos
date Tue, 07 Feb 2012 23:28:20 -0300
parents c8f378272407
children 5f1e3d35e113
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using AltNetHispano.Agendas.Domain;
using AltNetHispano.Agendas.Factories;
using AltNetHispano.Agendas.Web.Models;

namespace AltNetHispano.Agendas.Web
{
    public static class DataProviders
    {
        public static IEnumerable<SelectListItem> GetTiposEvento(this HtmlHelper helper)
        {
            return from t in EventoModelHelper.GetTiposEventos()
                   select new SelectListItem {Text = t.TipoEventoStr, Value = t.TipoEvento.ToString()};
        }

		public static IEnumerable<SelectListItem> GetPonentes(this HtmlHelper helper, IEnumerable<Guid> ids)
		{
			var personas = AgendaFactory.GetPersonaService();
			if (ids == null || !ids.Any()) return new SelectListItem[] {};

			return from p in from id in ids
				   select personas.GetById(id)
				   select new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() };
		}


		public static IEnumerable<SelectListItem> GetPonentesExcepto(this HtmlHelper helper, IEnumerable<Guid> ids)
		{
			var personas = AgendaFactory.GetPersonaService();

			if (ids==null) ids = new List<Guid>();

			return from p in personas.GetAll() where !ids.Contains(p.Id)
				   select new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() };
		}
		
		public static IEnumerable<string> GetRoles(this HtmlHelper helper)
		{
			return new[] {Roles.Administrador, Roles.Usuario};
		}

		public static string Version(this HtmlHelper helper)
		{
			return typeof (DataProviders).Assembly.GetName().Version.ToString();
		}

		public static IEnumerable<SelectListItem> GetPatrocinadores(this HtmlHelper helper, IEnumerable<Guid> ids)
		{
			var repository = AgendaFactory.GetPatrocinadorRepository();

			var patrocinadores = repository.GetAll();
			if (ids == null || !ids.Any()) return new SelectListItem[] { };

			return from p in patrocinadores
			       select new SelectListItem {Text = p.Nombre, Value = p.Id.ToString()};
		}

		public static IEnumerable<SelectListItem> GetPatrocinadoresExcepto(this HtmlHelper helper, IEnumerable<Guid> ids)
		{
			var repository = AgendaFactory.GetPatrocinadorRepository();

			var patrocinadores = repository.GetAll();
			if (ids == null) ids = new List<Guid>();

			return from p in patrocinadores
				   where !ids.Contains(p.Id)
				   select new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() };
		}
	}
}