using CD67.FicheCollege.Entity;
using CD67.FicheCollege.Entity.WsAgents;
using CD67.FicheCollege.Entity.WsExternes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace CD67.FicheCollege.Entity
{
///
/// Classe d'extension de celle d'Entity, nécessaire pour y associer les Metadata
///
[MetadataType(typeof(College_Metadata))]
public partial class College
{
public string AdresseComplete => $"{this.Adresse}\n{this.Code_Postal} {this.Commune}";
public WsExternes.Agent principal;
public WsExternes.Agent adjoint;
public WsAgents.Agent gestionnaire1;
public WsAgents.Agent gestionnaire2;
public Dictionary educfData = new Dictionary();
// Charge les données d'identité des agents depuis le web-service
public void hydrate()
{
Entity.WsExternes.WsExternes wsExternes = new Entity.WsExternes.WsExternes();
wsExternes.UseDefaultCredentials = true;
Entity.WsAgents.WsAgents wsAgents = new Entity.WsAgents.WsAgents();
wsAgents.UseDefaultCredentials = true;
if (!String.IsNullOrEmpty(PrincipalSid))
{
principal = wsExternes.GetById(PrincipalSid);
}
if (!String.IsNullOrEmpty(AdjointSid))
{
adjoint = wsExternes.GetById(AdjointSid);
}
if (!String.IsNullOrEmpty(Gestionnaire1Sid))
{
gestionnaire1 = wsAgents.GetById(Gestionnaire1Sid);
}
if (!String.IsNullOrEmpty(Gestionnaire2Sid))
{
gestionnaire2 = wsAgents.GetById(Gestionnaire2Sid);
}
}
public College flat()
{
return new College()
{
Id = Id,
Annee_Id = Annee_Id,
CodeRne = CodeRne,
Libelle = Libelle,
Adresse = Adresse,
Code_Postal = Code_Postal,
TypeCollege_Id = TypeCollege_Id,
Commune_Insee = Commune_Insee,
Commune = Commune,
Canton = Canton,
Territoire_Id = Territoire_Id,
TAD = TAD,
CDC = CDC,
Tel = Tel,
Fax = Fax,
Email = Email,
PrincipalSid = PrincipalSid,
AdjointSid = AdjointSid,
Gestionnaire1Sid = Gestionnaire1Sid,
Gestionnaire2Sid = Gestionnaire2Sid,
TokenId = TokenId,
RestaurationType_Id = RestaurationType_Id
};
}
}
///
/// Classe contenant les DataAnnotations pour chaque champ
///
public class College_Metadata
{
[Required]
public string Id { get; set; }
[Required]
[Display(Name = "Code RNE du collège")]
public string CodeRne { get; set; }
[Required]
[Display(Name = "Année scolaire")]
public string Annee_Id { get; set; }
[Required]
[Display(Name = "Nom")]
public string Libelle { get; set; }
[Display(Name = "Adresse")]
public string Adresse { get; set; }
[Display(Name = "Code postal")]
public string Code_Postal { get; set; }
[Display(Name = "Type d'établissement")]
public int TypeCollege_Id { get; set; }
[Display(Name = "Code INSEE")]
public string Commune_Insee { get; set; }
[Required]
[Display(Name = "Commune")]
public string Commune { get; set; }
[Display(Name = "Canton de rattachement")]
public string Canton { get; set; }
[Display(Name = "Territoire de rattachement")]
public string Territoire_Id { get; set; }
[Display(Name = "TAD")]
public string TAD { get; set; }
[Display(Name = "CDC")]
public string CDC { get; set; }
[Display(Name = "Téléphone")]
public string Tel { get; set; }
[Display(Name = "Fax")]
public string Fax { get; set; }
[Display(Name = "EMail")]
public string Email { get; set; }
[Display(Name = "Principal")]
public string PrincipalSid { get; set; }
[Display(Name = "Adjoint")]
public string AdjointSid { get; set; }
[Display(Name = "Gestionnaire 1")]
public string Gestionnaire1Sid { get; set; }
[Display(Name = "Gestionnaire 2")]
public string Gestionnaire2Sid { get; set; }
public Guid TokenId { get; set; }
[Display(Name = "Type de restauration")]
public int RestaurationType_Id { get; set; }
}
}