コード例 #1
0
ファイル: GitHubApi.cs プロジェクト: jaredpar/ConversionTools
        private async Task GetRepositories()
        {
            _log.Write(LogLevel.Debug, "Fetching repositories for current user");
            Repositories.Clear();
            Organizations.Clear();

            try
            {
                var repositories = await _github.Repository.GetAllForCurrent();

                AddRepositories(repositories);
                var organizations = await _github.Organization.GetAllForCurrent();

                foreach (var organization in organizations)
                {
                    repositories = await _github.Repository.GetAllForOrg(organization.Login);

                    AddRepositories(repositories);
                }
                OnRepositoriesComplete();
            }
            catch (Exception exception)
            {
                _log.Write(LogLevel.Warn, "Failed to get repository data", exception);
            }
        }
コード例 #2
0
        public async Task Init()
        {
            IsFinishedLoading = false;

            var data = await _organizationsService.Get <IEnumerable <OrganizationDTO> >(
                new OrganizationSearchRequest {
                RatingMin              = RatingMin,
                DistanceKilometers     = DistanceKilometers,
                DeliveryTimeMinutesMax = DeliveryTimeMinutesMax,
                AverageProductPriceMax = AveragePriceMax,
                OrganizationType       = new OrganizationTypeDTO()
            });

            Organizations.Clear();
            foreach (var item in data)
            {
                Organizations.Add(new OrganizationModel
                {
                    Organization = item,
                    ProfilePhoto = $"{APIService._apiUrl}/Organization/ProfilePhoto/{item.Id}"
                });
            }

            IsFinishedLoading = true;
        }
コード例 #3
0
 public void Update(Config config)
 {
     Organizations.Clear();
     foreach (var item in config.Organizations)
     {
         Organizations.Add(item);
     }
 }
コード例 #4
0
 public void ClearAll()
 {
     Operations.Clear();
     Processes.Clear();
     Organizations.Clear();
     Threads.Clear();
     Categories.Clear();
     Users.Clear();
     Levels.Clear();
     RequestIds.Clear();
 }
コード例 #5
0
ファイル: GitHubApi.cs プロジェクト: jaredpar/ConversionTools
 public override void Logout()
 {
     _log.Write(LogLevel.Info, "Logging out of GitHub");
     base.Logout();
     SettingsCache.Credentials = null;
     User = null;
     Repositories.Clear();
     Organizations.Clear();
     AllIssues.Clear();
     OnPropertyChanged("Issues");
 }
コード例 #6
0
        /// <summary>
        /// Initialization users, groups and organizations collections. Initialization links between these entities
        /// </summary>
        private void Fill()
        {
            Users.Clear();
            FilteredUsers.Clear();
            var users = _userService.GetAllSorted(false)?.ToList();

            if (users == null || !users.Any())
            {
                return;
            }
            users.Sort((u1, u2) => u1.UserName.CompareTo(u2.UserName));
            users.ForEach(u => Users.Add(new UserViewModel(u)));
            FilteredUsers  = new ObservableCollection <UserViewModel>(Users);
            FilteredUsers2 = new ObservableCollection <UserViewModel>(Users);

            Groups.Clear();
            var groups = _groupService.GetAllSortedByName()?.ToList();

            if (groups == null || !groups.Any())
            {
                return;
            }
            groups.ForEach(g => Groups.Add(new GroupViewModel(g)));
            foreach (var u in Users)
            {
                var gs = _groupService.GetAllByUserId(u.UserId)?.ToList();
                if (gs == null || !gs.Any())
                {
                    continue;
                }
                gs.ForEach(g =>
                {
                    var groupViewModel = Groups.FirstOrDefault(gVm => gVm.GroupId == g.GroupId);
                    if (groupViewModel == null)
                    {
                        return;
                    }
                    u.Groups.Add(groupViewModel);
                    groupViewModel.Users.Add(u);
                });
            }

            Organizations.Clear();
            var organizations = _organizationService.GetAll()?.ToList();

            if (organizations == null || !organizations.Any())
            {
                return;
            }
            organizations.ForEach(o => Organizations.Add(new OrganizationViewModel(o)));
            foreach (var u in Users)
            {
                var orgs = _organizationService.GetByUserId(u.UserId)?.ToList();
                if (orgs == null || !orgs.Any())
                {
                    continue;
                }
                orgs.ForEach(o =>
                {
                    var orgViewModel = Organizations.FirstOrDefault(oVm => oVm.OrganizationId == o.Id);
                    if (orgViewModel == null)
                    {
                        return;
                    }
                    u.Organizations.Add(orgViewModel);
                    orgViewModel.Users.Add(u);
                });
            }
        }