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; }
private async Task SwitchTeamStateExecuted(Team team) { LoggingService.Trace("Executing TeamsListViewModel.SwitchTeamStateCommand"); if (IsBusy) { return; } IsBusy = true; try { var result = await _wasabeeApiV1Service.User_ChangeTeamState(team.Id, team.IsEnabled? "Off" : "On"); if (result) { team.IsEnabled = !team.IsEnabled; _userDialogs.Toast($"Location sharing state changed for team {team.Name}", TimeSpan.FromSeconds(3)); var updatedTeam = await _wasabeeApiV1Service.Teams_GetTeam(team.Id); if (updatedTeam != null) { await _teamsDatabase.SaveTeamModel(updatedTeam); } } else { _userDialogs.Toast("State can't be changed, please try again", TimeSpan.FromSeconds(3)); } } catch (Exception e) { LoggingService.Error(e, "Error Executing TeamsListViewModel.SwitchTeamStateCommand"); _userDialogs.Toast("Error occured, please retry", TimeSpan.FromSeconds(3)); } finally { IsBusy = false; } }