/// <summary> /// Add the specified <c>Principal</c> to the list of <c>Queue</c> members. /// <para> /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.addprincipaltoqueuerequest(v=crm.8).aspx /// </para> /// </summary> /// <param name="queueId"><c>Queue</c> Id</param> /// <param name="principalType"><c>System User</c> or <c>Team</c>. If the passed-in <c>PrincipalType.Team</c> , add each team member to the queue.</param> /// <param name="principalId"><c>Principal</c> Id</param> /// <returns> /// <see cref="AddPrincipalToQueueResponse"/> /// </returns> public AddPrincipalToQueueResponse AddPrincipalToQueue(Guid queueId, PrincipalType principalType, Guid principalId) { ExceptionThrow.IfGuidEmpty(queueId, "queueId"); ExceptionThrow.IfGuidEmpty(principalId, "principalId"); Entity principalEntity = null; switch (principalType) { case PrincipalType.SystemUser: SystemUserHelper systemuserHelper = new SystemUserHelper(this.OrganizationService); principalEntity = systemuserHelper.Get(principalId, "fullname"); break; case PrincipalType.Team: TeamHelper teamHelper = new TeamHelper(this.OrganizationService); principalEntity = teamHelper.Get(principalId, "name"); break; } ExceptionThrow.IfNull(principalEntity, "principal", string.Format("Principal not found with '{0}'", principalId.ToString())); AddPrincipalToQueueRequest request = new AddPrincipalToQueueRequest() { QueueId = queueId, Principal = principalEntity }; return((AddPrincipalToQueueResponse)this.OrganizationService.Execute(request)); }