view Agendas/trunk/src/Agendas.Web/DataProviders.cs @ 239:717fce60f200

Se eliminió un warning que aparecía por ocultar un método.
author juanjose.montesdeocaarbos
date Wed, 05 Oct 2011 07:31:35 -0300
parents e5959f3405e0
children b43dc14886e3
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, Guid id)
        {
        	var lista = new List<SelectListItem> {new SelectListItem {Text = "[Ninguno]", Value = Guid.Empty.ToString()}};

            var personaService = AgendaFactory.GetPersonaService();
        	var personas = from p in personaService.GetAll()
        	               orderby p.Nombre
        	               select
        	               	new SelectListItem {Text = p.Nombre, Value = p.Id.ToString(), Selected = p.Id.Equals(id)};

        	return lista.Union(personas);
        }

		public static IEnumerable<SelectListItem> GetOtrosPonentes(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> GetOtrosPonentesExcepto(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};
		}
	}
}