public static string SetForumsModerators(string sfid, string moderators, int inherited) { //BBX.Data.Moderators.DeleteModeratorByFid(int.Parse(fid)); var fid = Int32.Parse(sfid); var f = XForum.FindByID(fid); Moderator.DeleteByFid(fid); if (inherited == 1) { string fids = "-1"; //while (true) //{ // var parentIdByFid = BBX.Data.Forums.GetParentIdByFid(fid); // if (parentIdByFid.Rows.Count <= 0) // { // break; // } // var text = parentIdByFid.Rows[0][0].ToString(); // if (text == "0" || String.IsNullOrEmpty(text)) break; // fids = fids + "," + text; //} if (f.AllChilds.Count > 0) { fids = f.AllChildKeyString; } int num = 1; //foreach (DataRow dataRow in BBX.Data.Moderators.GetUidModeratorByFid(fids).Rows) //{ // BBX.Data.Moderators.AddModerator(int.Parse(dataRow[0].ToString()), int.Parse(sfid), num, 1); // num++; //} foreach (var item in Moderator.FindAllIDsByFids(fids)) { var entity = new Moderator(); entity.Uid = item; entity.Fid = fid; entity.DisplayOrder = num++; entity.Inherited = 1; entity.Insert(); } } InsertForumsModerators(sfid, moderators, 1, 0); return(UpdateUserInfoWithModerator(moderators)); }