Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StartCityId,EndCityId,DateUpdated")] RoutDTO rout)
        {
            if (id != rout.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _dbAccess.EditRout(rout);
                    _dbAccess.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoutExists(rout.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var cities = _dbAccess.GetCities();

            ViewData["EndCityId"]   = new SelectList(cities, "Id", "Name", rout.EndCityId);
            ViewData["StartCityId"] = new SelectList(cities, "Id", "Name", rout.StartCityId);
            return(View(rout));
        }