public async Task <IActionResult> Create([Bind("IDStazione,CodiceStazione,NomeStazione,RitiroTessera,RiCaricaAbbonamento,Versione")] StazioneModel stazioneModel) { if (ModelState.IsValid) { _context.Add(stazioneModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(stazioneModel)); }
public async Task <IActionResult> Create([Bind(include: "IdPercorso,IdSottorete,Distanza,Versione")] PercorsiModel percorsiModel) { percorsiModel.IdStazioneOrigine = System.Convert.ToInt32(Request.Form["drpOriginalStation"]); percorsiModel.IdStazioneDestinazione = System.Convert.ToInt32(Request.Form["drpDestinationStation"]); percorsiModel.IdVia1 = System.Convert.ToInt32(Request.Form["drpVia1Station"]); percorsiModel.IdVia2 = System.Convert.ToInt32(Request.Form["drpVia2Station"]); if (ModelState.IsValid) { _context.Add(percorsiModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } PathService pathService = new PathService(_context); ViewBag.originalStationsList = pathService.ReturnListStationsForDropDowns(percorsiModel.IdStazioneOrigine, false); ViewBag.destinationStationsList = pathService.ReturnListStationsForDropDowns(percorsiModel.IdStazioneDestinazione, false); ViewBag.via1StationsList = pathService.ReturnListStationsForDropDowns(percorsiModel.IdVia1, true); ViewBag.via2StationsList = pathService.ReturnListStationsForDropDowns(percorsiModel.IdVia2, true); return(View(percorsiModel)); }