Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AdventureMapID,FromWaypointID,ToWaypointID")] newAdventureMap newAdventureMap)
        {
            if (id != newAdventureMap.AdventureMapID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(newAdventureMap);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!newAdventureMapExists(newAdventureMap.AdventureMapID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FromWaypointID"] = new SelectList(_context.Waypoint, "WaypointID", "WaypointID", newAdventureMap.FromWaypointID);
            ViewData["ToWaypointID"]   = new SelectList(_context.Waypoint, "WaypointID", "WaypointID", newAdventureMap.ToWaypointID);
            return(View(newAdventureMap));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("AdventureMapID,FromWaypointID,ToWaypointID")] newAdventureMap newAdventureMap)
        {
            if (ModelState.IsValid)
            {
                _context.Add(newAdventureMap);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FromWaypointID"] = new SelectList(_context.Waypoint, "WaypointID", "WaypointID", newAdventureMap.FromWaypointID);
            ViewData["ToWaypointID"]   = new SelectList(_context.Waypoint, "WaypointID", "WaypointID", newAdventureMap.ToWaypointID);
            return(View(newAdventureMap));
        }