public ActionResult AddMember(string userid, string groupID) { string me = whoami(); MembershipHelper.CheckAdmin(groupID, me); Membership member = _groupManager.AddMember(groupID, userid); MembershipHelper.RefreshJoinedGroup(userid); return(ActionResult.Success()); }
/// <summary> /// メンバー登録 /// </summary> public void AddMember() { var url = this.textBoxUrl.Text; var username = this.textBoxUser.Text; var password = this.textBoxPassword.Text; var gm = new GroupManager(url, username, password); gm.ThrowSharePointException += (_sender, _e) => { throw new ApplicationException(_e.ErrorMessage); }; var userLs = gm.SiteUsers.ToDictionary(u => u.Title); var tbl = this.gridCsv.ToDataTable(); var gls = tbl.Select(r => new { グループ名 = r["グループ名"].ToString(), メンバー名 = r["メンバー名"].ToString(), }).GroupBy(r => new { r.グループ名, }).ToList(); var sb = new StringBuilder(); gls.ForEach(gg => { var groupName = gg.Key.グループ名; sb.AppendLine("グループ名:" + groupName); gg.ToList().ForEach(u1 => { var userName = u1.メンバー名; sb.Append(" メンバー名:").Append(userName); if (userLs.ContainsKey(userName)) { var user = userLs[userName]; gm.AddMember(groupName, user); sb.Append("を追加しました。").AppendLine(); } else { sb.Append(" ※ユーザがみつかりませんでした。").AppendLine(); } }); }); this.ShowMessageBox(sb.ToString()); }
public ActionResult Group(group model, string groupBut) { GroupManager GM = new GroupManager(); if (groupBut.Equals("Join Group")) { GM.AddMember(model, User.Identity.Name); return(View(model)); } else if (groupBut.Equals("Leave Group")) { GM.RemoveMember(model, User.Identity.Name); return(RedirectToAction("Groups", "Account")); } else if (groupBut.Equals("Manage Group")) { return(RedirectToAction("ManageGroup", new { g_id = model.group_id })); } return(View(model)); }