public async Task <IActionResult> HelpDetail(int?id, Help model, int pid = 0) { var now = DateTime.Now; var result = new Result(); if (model.Title.IsNullOrEmpty()) { result.Error("请输入中文名称"); return(Json(result)); } if (!model.Content.IsNullOrEmpty()) { model.Content = model.Content.RemoveHtml(); } if (id.HasValue && id.Value > 0 && pid == 0) { var old = DefaultStorage.HelpGet(id.Value); if (old == null) { result.Message = "数据不存在"; return(Json(result)); } var status = await TryUpdateModelAsync(old); if (status) { result.Status = DefaultStorage.HelpUpdate(old); if (!result.Status) { result.Message = "更新失败"; } } else { result.Message = "参数有误"; } return(Json(result)); } if (id.HasValue && id.Value == 0 && pid == 0) { result.Message = "参数错误"; return(Json(result)); } model.CreatedOn = now; model.ModifiedBy = string.Empty; model.ModifiedOn = now; var hs = DefaultStorage.HelpPidList(pid); model.Depth = hs.Count + 1; model.Path = string.Join(",", hs); var newId = DefaultStorage.HelpCreate(model); if (result.Status = newId > 0) { hs.Add(newId);//补全path var path = string.Join(",", hs); DefaultStorage.HelpPathUpdate(newId, path); result.Success(); } return(Json(result)); }