コード例 #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("ID,Body,Subject")] Article article)
        {
            if (id != article.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(article);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArticleExists(article.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(article));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,FederalDistrictID")] FederalSubject federalSubject)
        {
            if (id != federalSubject.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(federalSubject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FederalSubjectExists(federalSubject.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FederalDistrictID"] = new SelectList(_context.FederalDistricts, "ID", "ID", federalSubject.FederalDistrictID);
            return(View(federalSubject));
        }