CollegeViewModel.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. using CD67.FicheCollege.Entity;
  2. using CD67.FicheCollege.Factory;
  3. using CD67.FicheCollege.MVC.Internal;
  4. using System.Collections.Generic;
  5. using System.Web.Mvc;
  6. namespace CD67.FicheCollege.MVC.Models
  7. {
  8. public class CollegeViewModel : BaseViewModel<College>
  9. {
  10. public SelectList Sel_TypesCollege;
  11. public SelectList Sel_CodesPostaux;
  12. public SelectList Sel_Territoires;
  13. public CollegeViewModel(College model, Entities dbContext, ModeAcces acces = ModeAcces.Lecture, Dictionary<string, object> bag = null) : base(model, acces, bag)
  14. {
  15. if (acces == ModeAcces.Creation | acces == ModeAcces.Modification)
  16. {
  17. TypeCollegeFactory fact = new TypeCollegeFactory(dbContext);
  18. Sel_TypesCollege = new SelectList(fact.getAll(), "Id", "Libelle", Obj.TypeCollege_Id);
  19. TerritoireFactory fact_t = new TerritoireFactory(dbContext);
  20. Sel_Territoires = new SelectList(fact_t.getAll(), "Id", "Libelle", Obj.Territoire_Id);
  21. Sel_CodesPostaux = new SelectList(Referentiel.GetCodesPostaux(Obj.Commune_Insee), Obj.Code_Postal);
  22. }
  23. }
  24. public override int Annee_Id { get { return Obj.Annee.Id; } }
  25. public override string Annee_Lib { get { return Obj.Annee.Libelle; } }
  26. }
  27. }