public InformationsModels getModel() { //récupère les données ServiceVehicule.VehicleAnalysisType[] response = (ServiceVehicule.VehicleAnalysisType[])Session["Analyse"]; //récupération de liste des VinNumbers var liste = new List <SelectListItem>(); try { for (int i = 0; i < response.Length; i++) { liste.Add(new SelectListItem { Text = response[i].BasicInformation.VinNumber, Value = i.ToString() }); } } catch { liste.Add(new SelectListItem { Text = "--aucun véhicule abonné--", Value = "0" }); } //création du modèle var model = new InformationsModels { //création des types d'informations sélectionnables EnumTypeInfo = new[] { new SelectListItem { Text = "basiques", Value = "basiques" }, new SelectListItem { Text = "de consommation", Value = "de consommation" }, new SelectListItem { Text = "de conduite", Value = "de conduite" }, new SelectListItem { Text = "de maintenance", Value = "de maintenance" }, new SelectListItem { Text = "complètes", Value = "complètes" } }, EnumVinNumber = liste }; return(model); }
public ActionResult Informations(InformationsModels model) { if (Request.IsAuthenticated) { //récupère les données ServiceVehicule.VehicleAnalysisType[] response = (ServiceVehicule.VehicleAnalysisType[])Session["Analyse"]; try { InformationsModels newModel = getModel(); newModel.SelectedVinNumber = model.SelectedVinNumber; newModel.SelectedTypeInfo = model.SelectedTypeInfo; newModel.InfosExperts = response[Convert.ToInt32(model.SelectedVinNumber)]; return(View(newModel)); } catch { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("LogOn", "Account")); } }