using CD67.FicheCollege.Entity.WsTiers;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace CD67.FicheCollege.Entity
{
    /// <summary>
    /// Classe d'extension de celle d'Entity, nécessaire pour y associer les Metadata
    /// </summary>
    [MetadataType(typeof(ActionEdu_Metadata))]
    public partial class ActionEdu
    {
        public long? totalEleves
        {
            get
            {
                return this.ActionsEduColleges.Sum(a => a.NbEleves);
            }
        }

        public Tiers tiers;

        public ActionEdu flat()
        {
            return new ActionEdu()
            {
                Id = Id,
                Numero = Numero,
                Nom = Nom,
                Montant = Montant,
                Description = Description,
                CommentaireInterne = CommentaireInterne,
                CommentairePublic = CommentairePublic,
                Neutralise = Neutralise,
                Ordre = Ordre,
                ActionEduThematiqueId = ActionEduThematiqueId,
                StatutId = StatutId,
                AnneeId = AnneeId,
                TokenId = TokenId
            };
        }
    }

    /// <summary>
    /// Classe contenant les DataAnnotations pour chaque champ
    /// </summary>
    public class ActionEdu_Metadata
    {
        [Required]
        public int Id { get; set; }

        [Required]
        [Display(Name = "Année")]
        public int AnneeId { get; set; }

        [Required]
        [Display(Name = "Numéro")]
        public int Numero { get; set; }

        [Required]
        [Display(Name = "Thématique")]
        public int ActionEduThematiqueId { get; set; }

        [Required]
        [Display(Name = "Nom")]
        public string Nom { get; set; }

        [Required]
        [Display(Name = "Statut")]
        public int StatutId { get; set; }

        [DataType(DataType.Currency)]
        [Display(Name = "Montant indicatif")]
        public decimal Montant { get; set; }

        [Display(Name = "Description")]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }

        [Display(Name = "Commentaire Public")]
        [DataType(DataType.MultilineText)]
        public string CommentairePublic { get; set; }

        [Display(Name = "Commentaire Interne")]
        [DataType(DataType.MultilineText)]
        public string CommentaireInterne { get; set; }

        [Display(Name = "Neutralisé (oui/non)")]
        public bool Neutralise { get; set; }

        public int Ordre { get; set; }
    }
}