コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Name")] BbsProvince bbsProvince)
        {
            if (id != bbsProvince.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bbsProvince);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BbsProvinceExists(bbsProvince.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bbsProvince));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Code,Name")] BbsProvince bbsProvince)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bbsProvince);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bbsProvince));
        }