コード例 #1
0
        public IActionResult Edit(int id, [Bind("Name,Id,TimeStamp")] Make make)
        {
            if (id != make.Id)
            {
                return(NotFound());
            }

            _repo.Update(make);
            return(RedirectToAction(nameof(Index)));
        }
コード例 #2
0
ファイル: Edit.cshtml.cs プロジェクト: wddot/presentations
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            try
            {
                _repo.Update(Make);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(Page());
            }

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
        public IActionResult Edit(int id, [Bind("Name,Id,TimeStamp")] Make make)
        {
            if (id != make.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(View(make));
            }

            try
            {
                _repo.Update(make);
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View(make));
            }
        }