コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryID,Country,DateEntered")] VacationCategory vacationCategory)
        {
            if (id != vacationCategory.CategoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vacationCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VacationCategoryExists(vacationCategory.CategoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vacationCategory));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("CategoryID,Country,DateEntered")] VacationCategory vacationCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vacationCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vacationCategory));
        }
コード例 #3
0
        }                                                            //NOTE: This will be the name of our table. Also, this table name will be used in TravelerProfiles later on when we do our Linq queries (e.g. when we add new data in the CREATE method).

        public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options)
            : base(options)
        {
            var tolist = VacationCategory.Include("VacationPlaces").ToList();
        }