コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("VisitRideId,VisitId,RideId,VisitRideRating,VisitRideComments")] VisitRide visitRide)
        {
            if (id != visitRide.VisitRideId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(visitRide);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VisitRideExists(visitRide.VisitRideId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RideId"]  = new SelectList(_context.Rides, "RideId", "RideId", visitRide.RideId);
            ViewData["VisitId"] = new SelectList(_context.Visits, "VisitId", "VisitId", visitRide.VisitId);
            return(View(visitRide));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("VisitRideId,VisitId,RideId,VisitRideRating,VisitRideComments")] VisitRide visitRide)
        {
            if (ModelState.IsValid)
            {
                _context.Add(visitRide);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RideId"]  = new SelectList(_context.Rides, "RideId", "RideId", visitRide.RideId);
            ViewData["VisitId"] = new SelectList(_context.Visits, "VisitId", "VisitId", visitRide.VisitId);
            return(View(visitRide));
        }