コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ShowId,Date,Time,VenueId")] ScheduleListViewModel scheduleListViewModel)
        {
            if (id != scheduleListViewModel.ShowId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(scheduleListViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScheduleListViewModelExists(scheduleListViewModel.ShowId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VenueId"] = new SelectList(_context.Venue, "VenueId", "Location", scheduleListViewModel.VenueId);
            return(View(scheduleListViewModel));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ShowId,Date,Time,VenueId")] ScheduleListViewModel scheduleListViewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(scheduleListViewModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VenueId"] = new SelectList(_context.Venue, "VenueId", "Location", scheduleListViewModel.VenueId);
            return(View(scheduleListViewModel));
        }