public ActionResult Delete(int id) { AjaxResult result = new AjaxResult(); try { QuestionClass entity = m_FTISService.GetQuestionClassById(id); //檢查底下的Question數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("QuestionClassId", id.ToString()); int subsCount = m_FTISService.GetQuestionCount(conditions); if (subsCount > 0) { return(this.Json(new AjaxResult(AjaxResultStatus.Fail, string.Format("{0}底下尚有Q&A,不可刪除。", entity.Name)))); } m_FTISService.DeleteQuestionClass(entity); result.ErrorCode = AjaxResultStatus.Success; result.Message = string.Format("{0}刪除成功", entity.Name); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Exception; result.Message = ex.Message; } return(this.Json(result)); }