private void FillSelect(Viking viking) { TypeVikingFactory typeVikingFactory = new TypeVikingFactory(db); ViewBag.ID_TYPE = new SelectList(typeVikingFactory.GetAll(), "Id", "TypeVikingId", viking.TypeViking); //Chargement d'une liste vide à la création TypeVikingFactory sousTypeFactory = new TypeVikingFactory(db); ViewBag.ID_SOUS_TYPE = new SelectList(sousTypeFactory.getManyBy(viking.TypeVikingId).OrderBy(i => i.Value), "Key", "Value", viking.TypeViking); }
public SelectList getListeTypesViking(string defaultSelected) { TypeVikingFactory typeVikingfactory = new TypeVikingFactory(db); List <TypeViking> getlist = typeVikingfactory.GetAll().ToList(); List <SelectListItem> listTypeViking = new List <SelectListItem>(); foreach (TypeViking item in getlist) { listTypeViking.Add(new SelectListItem { Text = item.Id + " - " + item.Libelle, Value = item.Id.ToString() }); } if (defaultSelected == string.Empty) { defaultSelected = ""; } return(new SelectList(listTypeViking, "Value", "Text", defaultSelected)); }
// GET: TypeViking public ActionResult Index() { TypeVikingFactory typeVikingFactory = new TypeVikingFactory(db); return(View(typeVikingFactory.GetAll())); }