public Task <List <PostPublicityScope> > GetPossiblePostPublicityScopesAsync(CancellationTokenSource cancellationTokenSource) => Task <List <PostPublicityScope> > .Run(async() => { if (!CrossConnectivity.Current.IsConnected) { throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION); } List <PostPublicityScope> possiblePublicityScopes = null; try { List <PostPublicityScope> groupsScope = _postPublicityScopeFactory.BuildRawPublicityScope(await _groupsService.GetGroupsAsync(cancellationTokenSource)); List <PostPublicityScope> teamMembersScope = _postPublicityScopeFactory.BuildRawPublicityScope(await _teamMemberService.GetTeamMembersAsync(cancellationTokenSource.Token, GlobalSettings.Instance.UserProfile.ProfileType == ProfileType.Parent)); PostPublicityScope familyPostPublicity = _postPublicityScopeFactory.BuildFamilyPublicityScope(await _familyService.GetFamilyAsync(cancellationTokenSource)); possiblePublicityScopes = _postPublicityScopeFactory.BuildCompletedPublicityScopeList(groupsScope.Concat(teamMembersScope).ToArray(), familyPostPublicity); } catch (ServiceAuthenticationException exc) { _identityUtilService.RefreshToken(); throw exc; } catch (Exception exc) { Crashes.TrackError(exc); possiblePublicityScopes = _postPublicityScopeFactory.BuildCompletedPublicityScopeList(null); } return(possiblePublicityScopes); }, cancellationTokenSource.Token);
public List <PostPublicityScope> BuildCompletedPublicityScopeList(IEnumerable <PostPublicityScope> publicityItems) { PostPublicityScope[] onlyPublic = new PostPublicityScope[] { new PostPublicityScope() { Title = PUBLIC_SCOPE_TITLE, Id = 0, PolicyType = PostPolicyType.Public } }; return((publicityItems == null) ? onlyPublic.ToList() : onlyPublic.Concat(publicityItems).ToList()); }
public PostPublicityScope BuildFamilyPublicityScope(FamilyDTO familyDTO) { PostPublicityScope postPublicityScope = null; if (familyDTO != null) { postPublicityScope = new PostPublicityScope() { Id = familyDTO.Id, Title = FAMILY_SCOPE_TITLE, PolicyType = PostPolicyType.Family }; } return(postPublicityScope); }
public List <PostPublicityScope> BuildCompletedPublicityScopeList(IEnumerable <PostPublicityScope> publicityItems, PostPublicityScope familyscopeItem) { List <PostPublicityScope> publicityScope = new List <PostPublicityScope>() { new PostPublicityScope() { Title = PUBLIC_SCOPE_TITLE, Id = 0 } }; if (familyscopeItem != null) { publicityScope.Add(familyscopeItem); } return((publicityItems == null) ? publicityScope : publicityScope.Concat(publicityItems).ToList()); }