Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/Models/PersonaModel.cs @ 259:e6c041d8e1bf
Ticket #193.1: Al guardar (nuevo/modificar) una persona, que la cuenta de twitter no comience con @
author | juanjose.montesdeocaarbos |
---|---|
date | Thu, 20 Oct 2011 08:16:55 -0300 |
parents | 730b80afa70d |
children | 8a2a58b5e2d6 |
comparison
equal
deleted
inserted
replaced
258:52fe43e36f5f | 259:e6c041d8e1bf |
---|---|
1 using System; | 1 using System; |
2 using System.Collections.Generic; | 2 using System.Collections.Generic; |
3 //using System.ComponentModel.DataAnnotations; | |
3 using System.ComponentModel.DataAnnotations; | 4 using System.ComponentModel.DataAnnotations; |
4 using System.Web.Mvc; | 5 using System.Web.Mvc; |
6 using DataAnnotationsExtensions; | |
7 | |
5 | 8 |
6 namespace AltNetHispano.Agendas.Web.Models | 9 namespace AltNetHispano.Agendas.Web.Models |
7 { | 10 { |
8 public class PersonaIndexModel{ | 11 public class PersonaIndexModel{ |
9 public IEnumerable<PersonaDto> Items { get; set; } | 12 public IEnumerable<PersonaDto> Items { get; set; } |
13 { | 16 { |
14 [Required] | 17 [Required] |
15 public string Nombre { get; set; } | 18 public string Nombre { get; set; } |
16 | 19 |
17 [Required] | 20 [Required] |
21 [CustomValidation(typeof(PersonaValidation), "IsTwitterAccount")] | |
18 public string Twitter { get; set; } | 22 public string Twitter { get; set; } |
19 | 23 |
20 [Required] | 24 [Required] |
25 [Email] | |
21 public string EMail { get; set; } | 26 public string EMail { get; set; } |
22 | 27 |
23 [DataType(DataType.Url)] | 28 [Url] |
24 public string Blog { get; set; } | 29 public string Blog { get; set; } |
25 | 30 |
26 public string[] Roles { get; set; } | 31 public string[] Roles { get; set; } |
27 } | 32 } |
28 | 33 |
34 | 39 |
35 [Required] | 40 [Required] |
36 public string Nombre { get; set; } | 41 public string Nombre { get; set; } |
37 | 42 |
38 [Required] | 43 [Required] |
44 [CustomValidation(typeof(PersonaValidation), "IsTwitterAccount")] | |
39 public string Twitter { get; set; } | 45 public string Twitter { get; set; } |
40 | 46 |
41 [Required] | 47 [Required] |
48 [Email] | |
42 public string EMail { get; set; } | 49 public string EMail { get; set; } |
43 | 50 |
44 [DataType(DataType.Url)] | 51 [Url] |
45 public string Blog { get; set; } | 52 public string Blog { get; set; } |
46 | 53 |
47 public string[] Roles { get; set; } | 54 public string[] Roles { get; set; } |
48 } | 55 } |
49 | 56 |
68 public string EMail { get; set; } | 75 public string EMail { get; set; } |
69 | 76 |
70 [HiddenInput] | 77 [HiddenInput] |
71 public string Blog { get; set; } | 78 public string Blog { get; set; } |
72 } | 79 } |
80 | |
81 //TODO: Ver donde movemos esta clase. | |
82 public class PersonaValidation | |
83 { | |
84 public static ValidationResult IsTwitterAccount(string value) | |
85 { | |
86 //[RegularExpression(@"^([\w\d\-\.]+)$")] | |
87 return value.StartsWith("@") | |
88 ? new ValidationResult("No debe ingresar el arroba al escribir la cuenta de twitter.") | |
89 : ValidationResult.Success; | |
90 } | |
91 } | |
92 | |
73 } | 93 } |