view Agendas/trunk/src/Agendas.Web/Models/PersonaModel.cs @ 288:a6037c6c88d8

Se soluciona bug #198 Bug: Summary incorrecto en Google Calendar. Se parametriza la hora en el mensaje.
author user@MECHUQUE
date Mon, 30 Jan 2012 01:52:47 -0300
parents 5ddc574deeea
children
line wrap: on
line source

using System;
using System.Collections.Generic;
//using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using DataAnnotationsExtensions;


namespace AltNetHispano.Agendas.Web.Models
{
    public class PersonaIndexModel{
        public IEnumerable<PersonaDto> Items { get; set; }
    }

    public class PersonaNewModel
    {
        [Required]
        public string Nombre { get; set; }

        [Required]
        [Twitter]
        public string Twitter { get; set; }

        [Required]
        [Email]
        public string EMail { get; set; }

		[Url]
    	public string Blog { get; set; }

		public string[] Roles { get; set; }
    }

    public class PersonaEditModel
    {
        [Required]
        [HiddenInput(DisplayValue = false)]
        public string Id { get; set; }

        [Required]
        public string Nombre { get; set; }

        [Required]
        [Twitter]
        public string Twitter { get; set; }

        [Required]
        [Email]
        public string EMail { get; set; }

        [Url]
    	public string Blog { get; set; }

		public string[] Roles { get; set; }
    }

    public class PersonaDto
    {
        public Guid Id { get; set; }
        public string Nombre { get; set; }
    }

    public class PersonaViewModel
    {
        [HiddenInput(DisplayValue = false)]
        public string Id { get; set; }

        [HiddenInput]
        public string Nombre { get; set; }

        [HiddenInput]
        public string Twitter { get; set; }

        [HiddenInput]
        public string EMail { get; set; }

        [HiddenInput]
        public string Blog { get; set; }
    }

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class TwitterAttribute: DataTypeAttribute
    {
        public TwitterAttribute()
            : base(DataType.Text)
        {
        }

        public override string FormatErrorMessage(string name)
        {

            if (ErrorMessage == null && ErrorMessageResourceName == null)
            {
                //TODO: Esto debe estar en el archivo de Recursos.
                const string TwitterAttribute_Invalid = "No debe ingresar el arroba al escribir la cuenta de twitter."; ;
                ErrorMessage = TwitterAttribute_Invalid;
            }
            return base.FormatErrorMessage(name);
        }

        public override bool IsValid(object value)
        {
            if (value == null)
            {
                return false;
            }

            return !((string)value).StartsWith("@");
        }
    }
}