| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Web;
- namespace AppliWebANA.Models {
- public enum Poste {
- Stagiaire,
- Chef,
- [Display(Name = "Sous-chef")]
- SousChef,
- Grouillot
- }
- public class Employe {
- [Required( ErrorMessage = "Le champ {0} est obligatware !" )]
- [Display( Name = "N° de membre du personnel" )]
- [CustomValidation(typeof( Validations ), "ValiderEmployeId")]
- public int Id { get; set; }
- [Required( ErrorMessage = "Le champ {0} est obligatware !" )]
- [Display( Name = "Prénom NOM" )]
- [StringLength( 50, MinimumLength = 2 )]
- [RegularExpression( "^[A-Z][a-z]*(-[A-Z][a-z]*)? [A-Z]+$", ErrorMessage = "Ça correspond pas à ^[A-Z][a-z]*(-[A-Z][a-z]*)? [A-Z]+$, CRÉTIN !")]
- public string Nom { get; set; }
- [Required( ErrorMessage = "Le champ {0} est obligatware !" )]
- public Poste Poste { get; set; }
- [Required( ErrorMessage = "Le champ {0} est obligatware !" )]
- [Range( 0, 7000, ErrorMessage = "Un sale air conforme à la politique de l'entrepise SVP !" )]
- public Decimal Salaire { get; set; }
- public static class Validations {
- public static ValidationResult ValiderEmployeId( int id ) {
- if( id % 2 == 1 ) {
- return new ValidationResult( $"Valeur {id} non-autorisée" );
- }
- return null;
- }
- }
- }
- }
|