public async Task <JsonResult> AddMember(string accountName, string memberName, bool isAdmin) { var account = GetAccount(accountName); if (account == null || ActionsRequiringPermissions.ManageMembership.CheckPermissions(GetCurrentUser(), account) != PermissionsCheckResult.Allowed) { return(Json(HttpStatusCode.Forbidden, Strings.Unauthorized)); } if (!account.Confirmed) { return(Json(HttpStatusCode.BadRequest, Strings.Member_OrganizationUnconfirmed)); } try { var request = await UserService.AddMembershipRequestAsync(account, memberName, isAdmin); var currentUser = GetCurrentUser(); var profileUrl = Url.User(account, relativeUrl: false); var confirmUrl = Url.AcceptOrganizationMembershipRequest(request, relativeUrl: false); var rejectUrl = Url.RejectOrganizationMembershipRequest(request, relativeUrl: false); var cancelUrl = Url.CancelOrganizationMembershipRequest(memberName, relativeUrl: false); MessageService.SendOrganizationMembershipRequest(account, request.NewMember, currentUser, request.IsAdmin, profileUrl, confirmUrl, rejectUrl); MessageService.SendOrganizationMembershipRequestInitiatedNotice(account, currentUser, request.NewMember, request.IsAdmin, cancelUrl); return(Json(new OrganizationMemberViewModel(request))); } catch (EntityException e) { return(Json(HttpStatusCode.BadRequest, e.Message)); } }