/// <summary> /// 更新主题页面隐藏状态 /// </summary> /// <param name="id">主题页面名称</param> /// <param name="isHide">隐藏状态</param> /// <returns>是否成功更新</returns> public static IMethodResult AdminUpdateTopicPageIsHide(String name, Boolean isHide) { if (!AdminManager.HasPermission(PermissionType.SuperAdministrator)) { throw new NoPermissionException(); } Boolean success = TopicPageRepository.Instance.UpdateEntityIsHide(name, isHide) > 0; if (!success) { return(MethodResult.FailedAndLog("No page was {0}!", isHide ? "hided" : "unhided")); } TopicPageCache.RemoveTopicPageCache(name);//删除缓存 return(MethodResult.SuccessAndLog("Admin {1} page, name = {0}", name, isHide ? "hide" : "unhide")); }
/// <summary> /// 更新一条主题页面 /// </summary> /// <param name="entity">对象实体</param> /// <param name="oldname">旧的主题页面名</param> /// <returns>是否成功更新</returns> public static IMethodResult AdminUpdateTopicPage(TopicPageEntity entity, String oldname) { if (!AdminManager.HasPermission(PermissionType.SuperAdministrator)) { throw new NoPermissionException(); } if (!RegexVerify.IsPageName(entity.PageName)) { return(MethodResult.InvalidRequest(RequestType.TopicPage)); } if (String.IsNullOrEmpty(entity.Title)) { return(MethodResult.FailedAndLog("Page title can not be NULL!")); } if (String.IsNullOrEmpty(entity.Description)) { return(MethodResult.FailedAndLog("Page description can not be NULL!")); } if (String.IsNullOrEmpty(entity.Content)) { return(MethodResult.FailedAndLog("Page content can not be NULL!")); } entity.LastDate = DateTime.Now; Boolean success = TopicPageRepository.Instance.UpdateEntity(entity, oldname) > 0; if (!success) { return(MethodResult.FailedAndLog("No page was updated!")); } TopicPageCache.RemoveTopicPageCache(oldname);//更新缓存 return(MethodResult.SuccessAndLog("Admin update page, name = {0}{1}", entity.PageName, (!String.Equals(oldname, entity.PageName, StringComparison.OrdinalIgnoreCase) ? ", previous = " + oldname : ""))); }
/// <summary> /// 删除指定ID的主题页面 /// </summary> /// <param name="ids">逗号分隔的主题页面ID</param> /// <returns>是否成功删除</returns> public static IMethodResult AdminDeleteTopicPages(String names) { if (!AdminManager.HasPermission(PermissionType.SuperAdministrator)) { throw new NoPermissionException(); } Boolean success = TopicPageRepository.Instance.DeleteEntities(names) > 0; if (!success) { return(MethodResult.FailedAndLog("No page was deleted!")); } names.ForEachInIDs(',', name => { TopicPageCache.RemoveTopicPageCache(name);//删除缓存 }); return(MethodResult.SuccessAndLog("Admin delete page, name = {0}", names)); }