コード例 #1
0
 public IActionResult Delete(int id, Make make)
 {
     if (id != make.Id)
     {
         return(BadRequest());
     }
     _repo.Delete(make);
     return(RedirectToAction(nameof(Index)));
 }
コード例 #2
0
        public IActionResult Delete(int id, Make entity)
        {
            if (id != entity.Id)
            {
                return(BadRequest());
            }

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