private List <SelectListItem> regions() { RegionContext regionContext = new RegionContext(connectionString); List <Region> regions = regionContext.GetAll(); List <SelectListItem> selectListItem = new List <SelectListItem>(); foreach (Region region in regions) { selectListItem.Add(new SelectListItem(region.Nom, region.Identifiant.ToString())); } return(selectListItem); }
public IActionResult Index() { ViewBag.Title = "Régions"; RegionIndexViewModels model = new RegionIndexViewModels(); model.Title = "Les Régions sont :"; RegionContext regionContext = new RegionContext(connectionString); List <Region> regions = regionContext.GetAll(); model.Regions = regions; return(View(model)); }