Beispiel #1
0
        private TeamMember TeamMemberToEntityAsync(TeamMemberModel model, string requestId = "")
        {
            var teamMember = TeamMember.Empty;

            teamMember.Id                       = model.Id;
            teamMember.DisplayName              = model.DisplayName;
            teamMember.RoleId                   = model.RoleId;
            teamMember.Fields                   = TeamMemberFields.Empty;
            teamMember.Fields.Mail              = model.Mail;
            teamMember.Fields.Title             = model.Title;
            teamMember.Fields.UserPrincipalName = model.UserPrincipalName;
            teamMember.ProcessStep              = model.ProcessStep;
            teamMember.Fields.Permissions       = new List <Permission>();
            foreach (var permission in model.Permissions)
            {
                teamMember.Fields.Permissions.Add(new Permission {
                    Id = permission.Id, Name = permission.Name
                });
            }
            teamMember.TeamsMembership = TeamsMembership.FromName(string.IsNullOrEmpty(model.TeamsMembership.Name) ? TeamsMembership.None.Name : model.TeamsMembership.Name);
            teamMember.RoleName        = model.RoleName;
            return(teamMember);
        }
        private async Task <IList <Role> > GetRoleListAsync(string requestId)
        {
            _logger.LogInformation($"RequestId: {requestId} - RolesRepo_GetRoleListAsync called.");

            try
            {
                var siteList = new SiteList
                {
                    SiteId = _appOptions.ProposalManagementRootSiteId,
                    ListId = _appOptions.RoleListId
                };

                dynamic json = await _graphSharePointAppService.GetListItemsAsync(siteList, "all", requestId);

                var itemsList = new List <Role>();
                if (json.value.HasValues)
                {
                    foreach (var item in json.value)
                    {
                        var obj = JObject.Parse(item.ToString()).SelectToken("fields");
                        itemsList.Add(new Role
                        {
                            Id              = obj.SelectToken("id")?.ToString(),
                            AdGroupName     = obj.SelectToken("AdGroupName")?.ToString(),
                            DisplayName     = obj.SelectToken("Role")?.ToString(),
                            TeamsMembership = obj.SelectToken("TeamsMembership") != null? TeamsMembership.FromName(obj.SelectToken("TeamsMembership").ToString()): TeamsMembership.None,
                            Permissions     = obj.SelectToken("Permissions") != null ? JsonConvert.DeserializeObject <IList <Permission> >(obj.SelectToken("Permissions").ToString(), new JsonSerializerSettings
                            {
                                MissingMemberHandling = MissingMemberHandling.Ignore,
                                NullValueHandling     = NullValueHandling.Ignore
                            }) : new List <Permission>()
                        });
                    }
                }

                return(itemsList);
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - RolesRepo_GetRoleListAsync error: {ex}");
                throw;
            }
        }