using CD67.FicheCollege.Entity; using CD67.FicheCollege.Factory; using CD67.FicheCollege.MVC.Internal; using System.Collections.Generic; using System.Web.Mvc; namespace CD67.FicheCollege.MVC.Models { public class CollegeViewModel : BaseViewModel { public SelectList Sel_TypesCollege; public SelectList Sel_CodesPostaux; public SelectList Sel_Territoires; public SelectList Sel_TypesRestauration; public CollegeViewModel(College model, Entities dbContext, ModeAcces acces = ModeAcces.Lecture, Dictionary bag = null) : base(model, acces, bag) { if (acces == ModeAcces.Creation | acces == ModeAcces.Modification) { TypeCollegeFactory fact = new TypeCollegeFactory(dbContext); Sel_TypesCollege = new SelectList(fact.getAll(), "Id", "Libelle", Obj.TypeCollege_Id); TerritoireFactory fact_t = new TerritoireFactory(dbContext); Sel_Territoires = new SelectList(fact_t.getAll(), "Id", "Libelle", Obj.Territoire_Id); Sel_CodesPostaux = new SelectList(Referentiel.GetCodesPostaux(Obj.Commune_Insee), Obj.Code_Postal); RestaurationTypeFactory type = new RestaurationTypeFactory(dbContext); Sel_TypesRestauration = new SelectList(type.getAllValid(), "Id", "Libelle", Obj.RestaurationType_Id); } } public override int Annee_Id { get { return Obj.Annee.Id; } } public override string Annee_Lib { get { return Obj.Annee.Libelle; } } } }