예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("WatchListHabitLoopId,HabitLoopId,WatchListId")] WatchListHabitLoop watchListHabitLoop)
        {
            if (id != watchListHabitLoop.WatchListHabitLoopId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(watchListHabitLoop);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WatchListHabitLoopExists(watchListHabitLoop.WatchListHabitLoopId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HabitLoopId"] = new SelectList(_context.HabitLoops, "HabitLoopId", "HabitLoopId", watchListHabitLoop.HabitLoopId);
            ViewData["WatchListId"] = new SelectList(_context.WatchLists, "WatchListId", "WatchListId", watchListHabitLoop.WatchListId);
            return(View(watchListHabitLoop));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("WatchListHabitLoopId,HabitLoopId,WatchListId")] WatchListHabitLoop watchListHabitLoop)
        {
            if (ModelState.IsValid)
            {
                _context.Add(watchListHabitLoop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HabitLoopId"] = new SelectList(_context.HabitLoops, "HabitLoopId", "HabitLoopId", watchListHabitLoop.HabitLoopId);
            ViewData["WatchListId"] = new SelectList(_context.WatchLists, "WatchListId", "WatchListId", watchListHabitLoop.WatchListId);
            return(View(watchListHabitLoop));
        }