private async Task RefreshExecuted()
        {
            LoggingService.Trace("Executing TeamDetailsViewModel.RefreshCommand");

            if (IsRefreshing)
            {
                return;
            }

            IsRefreshing = true;

            var updatedTeam = await _wasabeeApiV1Service.Teams_GetTeam(_teamId);

            if (updatedTeam != null)
            {
                await _teamsDatabase.SaveTeamModel(updatedTeam);

                Team = updatedTeam;
            }
            else
            {
                var localData = await _teamsDatabase.GetTeam(_teamId);

                if (localData != null)
                {
                    Team = localData;
                }
            }

            Title        = Team.Name;
            IsRefreshing = false;
        }
Пример #2
0
        private async void LoadOperationExecuted()
        {
            if (IsBusy)
            {
                return;
            }

            LoggingService.Trace("Executing OperationDetailViewModel.LoadOperationCommand");

            IsBusy = true;

            try
            {
                var op = await _operationsDatabase.GetOperationModel(_parameter !.OpId);

                if (op == null)
                {
                    return;
                }

                Operation = op;
                TeamsCollection.Clear();

                var loggedUserId = _userSettingsService.GetLoggedUserGoogleId();
                var userTeams    = await _usersDatabase.GetUserTeams(loggedUserId);

                var teamsIds = Operation.TeamList.Select(x => x.TeamId).ToList();
                foreach (var teamId in teamsIds)
                {
                    var team = await _teamsDatabase.GetTeam(teamId);

                    if (team != null && TeamsCollection.All(x => x.Id != team.Id))
                    {
                        var isOwner = userTeams.Any(x => x.Id.Equals(team.Id) && x.Owner.Equals(loggedUserId));
                        TeamsCollection.Add(new TeamItemSubViewModel(team.Id, team.Name)
                        {
                            IsOwner = isOwner
                        });
                    }
                }
            }
            catch (Exception e)
            {
                LoggingService.Error(e, "Error Executing OperationDetailViewModel.LoadOperationCommand");
            }
            finally
            {
                IsBusy = false;
            }
        }