示例#1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Route_StopId,StopId,RouteId,StopTime")] Route_Stop route_Stop)
        {
            if (id != route_Stop.Route_StopId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(route_Stop);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Route_StopExists(route_Stop.Route_StopId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RouteId"] = new SelectList(_context.Routes, "RouteId", "RouteId", route_Stop.RouteId);
            ViewData["StopId"]  = new SelectList(_context.Stops, "StopId", "StopId", route_Stop.StopId);
            return(View(route_Stop));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Route_StopId,StopId,RouteId,StopTime")] Route_Stop route_Stop)
        {
            if (ModelState.IsValid)
            {
                route_Stop.Route_StopId = Guid.NewGuid();
                _context.Add(route_Stop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RouteId"] = new SelectList(_context.Routes, "RouteId", "RouteId", route_Stop.RouteId);
            ViewData["StopId"]  = new SelectList(_context.Stops, "StopId", "StopId", route_Stop.StopId);
            return(View(route_Stop));
        }