public async Task <IActionResult> Deletes(params string[] itemId) { if (itemId == null || itemId.Length == 0) { AlertError("没有选择。"); } else { foreach (var item in itemId) { await _postManager.DeleteByIdAsync(item); } AlertSuccess("已删除。"); } return(RedirectToAction(nameof(List))); }
/// <summary> /// blogger.deletePost method /// </summary> /// <param name="appKey"> /// Key from application. Outdated methodology that has no use here. /// </param> /// <param name="postId"> /// post guid in string format /// </param> /// <param name="userName"> /// login username /// </param> /// <param name="password"> /// login password /// </param> /// <param name="publish"> /// mark as published? /// </param> /// <returns> /// Whether deletion was successful or not. /// </returns> internal async Task <bool> DeletePost(string appKey, string postId, string userName, string password, bool publish) { try { var user = GetVerifyUserAsync(userName, password); //if (!_permissionChecker.IsValid(user, PermissionKeys.PostDelete)) //{ // throw new MetaWeblogException("11", "User authentication failed"); //} await _postManager.DeleteByIdAsync(postId); } catch (Exception ex) { throw new MetaWeblogException("12", $"DeletePost failed. Error: {ex.Message}"); } return(true); }