async public Task <ActionResult> DeleteConfirmed(Guid id) { try { await repository.Delete(id); } catch (DataException) { return(RedirectToAction("DataError", "Error", new { area = "", message = "文章刪除錯誤" })); } return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(Guid id) { try { await repository.Delete(id); } catch (DataException) { ModelState.AddModelError("", "無法儲存,請聯絡網站管理員"); } return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(Guid id) { try { repository.Delete(id); db.SaveChanges(); } catch (DataException) { return(RedirectToAction("DataError", "Error", new { area = "", message = "刪除錯誤" })); } return(RedirectToAction("Index")); }