Esempio n. 1
0
        public async Task <CrateTeamFromGroupByIdOutputData> Execute(CrateTeamFromGroupByIdInputData request)
        {
            CrateTeamFromGroupByIdOutputData response = null;

            try
            {
                var teamSettings = new Microsoft.Graph.Team
                {
                    MemberSettings = new TeamMemberSettings
                    {
                        AllowCreatePrivateChannels = true,
                        AllowCreateUpdateChannels  = true,
                        ODataType = null
                    },
                    MessagingSettings = new TeamMessagingSettings
                    {
                        AllowUserEditMessages   = true,
                        AllowUserDeleteMessages = true,
                        ODataType = null
                    },
                    FunSettings = new TeamFunSettings
                    {
                        AllowGiphy         = true,
                        GiphyContentRating = GiphyRatingType.Strict,
                        ODataType          = null
                    },
                    ODataType = null
                };

                var team = await Graph.Groups[request.GUID].Team
                           .Request()
                           .PutAsync(teamSettings);

                response = new CrateTeamFromGroupByIdOutputData
                {
                    Team = new TeamModel(team)
                };

                logger.Information(
                    $"Type: CrateTeamFromGroupByIdActivity; Method: Execute; Info: Crate Team From Group By Id: {request.GUID} successfully");
            }
            catch (Exception e)
            {
                logger.Error($"Type: CrateTeamFromGroupByIdActivity; Method: Execute; Error: {e.Message}");
                throw;
            }

            return(await Task.FromResult(response));
        }
Esempio n. 2
0
        private static async Task <Microsoft.Graph.Team> TeamifyGroupAsync(GraphServiceClient client, string groupId)
        {
            var team = new Microsoft.Graph.Team
            {
                MemberSettings = new TeamMemberSettings
                {
                    AllowCreateUpdateChannels = true,
                    ODataType = null
                },
                MessagingSettings = new TeamMessagingSettings
                {
                    AllowUserEditMessages   = true,
                    AllowUserDeleteMessages = true,
                    ODataType = null
                },
                ODataType = null
            };

            var requestTeamifiedGroup = client.Groups[groupId].Team.Request();

            return(await requestTeamifiedGroup.PutAsync(team));
        }
        public async Task <CreateOrAddTeamOutputData> Execute(CreateOrAddTeamInputData request)
        {
            CreateOrAddTeamOutputData response = null;

            try
            {
                foreach (var item in request.List)
                {
                    var group = new Microsoft.Graph.Group
                    {
                        DisplayName = item.Name,
                        MailEnabled = true,
                        GroupTypes  = new List <string>
                        {
                            "Unified"
                        },
                        SecurityEnabled = false,
                        MailNickname    = TranslitHelper.Execute(item.Name.Replace(" ", "").Replace(".", "").ToLower())
                    };

                    var result = await Graph.Groups
                                 .Request()
                                 .AddAsync(group);

                    var owner = new DirectoryObject
                    {
                        Id = item.OwnerGUID
                    };

                    await Graph.Groups[result.Id].Owners.References
                    .Request()
                    .AddAsync(owner);

                    var teamSettings = new Microsoft.Graph.Team
                    {
                        MemberSettings = new TeamMemberSettings
                        {
                            AllowCreatePrivateChannels = true,
                            AllowCreateUpdateChannels  = true,
                            ODataType = null
                        },
                        MessagingSettings = new TeamMessagingSettings
                        {
                            AllowUserEditMessages   = true,
                            AllowUserDeleteMessages = true,
                            ODataType = null
                        },
                        FunSettings = new TeamFunSettings
                        {
                            AllowGiphy         = true,
                            GiphyContentRating = GiphyRatingType.Strict,
                            ODataType          = null
                        },
                        ODataType = null
                    };

                    var team = await Graph.Groups[result.Id].Team
                               .Request()
                               .PutAsync(teamSettings);


                    var conversationMember = new AadUserConversationMember
                    {
                        AdditionalData = new Dictionary <string, object>()
                    };

                    foreach (var row in item.ParticipantsList)
                    {
                        conversationMember.AdditionalData.Add(
                            "*****@*****.**", $"https://graph.microsoft.com/v1.0/users('{row}')");
                    }

                    await Graph.Teams[team.Id].Members
                    .Request()
                    .AddAsync(conversationMember);
                }

                response = new CreateOrAddTeamOutputData();

                logger.Information(
                    "Type: CreateOrAddTeamActivity; Method: Execute; Info: Create team for request successfully");
            }
            catch (Exception e)
            {
                logger.Error($"Type: CreateOrAddTeamActivity; Method: Execute; Error: {e.Message}");
                throw;
            }

            return(await Task.FromResult(response));
        }
Esempio n. 4
0
 /// <summary>
 /// Creates the specified Team using PUT.
 /// </summary>
 /// <param name="teamToCreate">The Team to create.</param>
 /// <returns>The created Team.</returns>
 public System.Threading.Tasks.Task <Team> PutAsync(Team teamToCreate)
 {
     return(this.PutAsync(teamToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified Team to the collection via POST.
 /// </summary>
 /// <param name="team">The Team to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created Team.</returns>
 public System.Threading.Tasks.Task <Team> AddAsync(Team team, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <Team>(team, cancellationToken));
 }
 /// <summary>
 /// Adds the specified Team to the collection via POST.
 /// </summary>
 /// <param name="team">The Team to add.</param>
 /// <returns>The created Team.</returns>
 public System.Threading.Tasks.Task <Team> AddAsync(Team team)
 {
     return(this.AddAsync(team, CancellationToken.None));
 }