public virtual IActionResult Delete(int id, string grid) { try { var item = Repo.GetItem(id); if (item == null) { return(new JavascriptResult(StringExt.JsAlert(UI.NotFound))); } if (OnDeleteCheck(item)) { if (Repo.Delete(item)) { OnAfterDelete(id); return(new JavascriptResult(!grid.IsEmpty() ? string.Format(DeleteJsAction2, grid) : DeleteJsAction)); } return(new JavascriptResult(StringExt.JsAlert(MvcLogger.GetErrorMessage(ModelState)))); } return(new JavascriptResult(StringExt.JsAlert(UI.NoAccess))); } catch (Exception ex) { return(new JavascriptResult(StringExt.JsAlert(MvcLogger.GetErrorMessage(ex)))); } }
public virtual async Task <IActionResult> Delete(int id, string grid) { if (!OnDeleteAuthCheck()) { return(new ForbidResult()); } try { var item = await GetDeleteItem(id); if (item == null) { return(new JavascriptResult(StringExt.JsAlert(UI.NotFound))); } DeleteGoBackUrl = Url.Action("Index"); if (OnDeleteCheck(item)) { if (await Repo.DeleteAsync(item)) { OnAfterDelete(id); if (!grid.IsEmpty()) { if (grid == "goback") { return(new JavascriptResult($"Goto('{DeleteGoBackUrl}')")); } else { return(new JavascriptResult(string.Format(DeleteJsAction2, grid))); } } else { return(new JavascriptResult(DeleteJsAction)); } } return(new JavascriptResult(StringExt.JsAlert(MvcLogger.GetErrorMessage(ModelState)))); } return(new JavascriptResult(StringExt.JsAlert(UI.NoAccess))); } catch (Exception ex) { return(new JavascriptResult(StringExt.JsAlert(MvcLogger.GetErrorMessage(ex)))); } }