private async void showRoutes(int?RouteID) { progRing.IsActive = true; progRing.Visibility = Visibility.Visible; RouteRepository r = new RouteRepository(); try { List <Route> routes; if (RouteID.GetValueOrDefault() > 0) { routes = await r.GetRoutesByRegion(RouteID.GetValueOrDefault()); } else { routes = await r.GetRoutes(); } routeList.ItemsSource = routes.OrderBy(e => e.ID); } catch (ApiException apiEx) { var sbuilder = new StringBuilder(); sbuilder.AppendLine("Errors:"); foreach (var error in apiEx.Errors) { sbuilder.AppendLine("-" + error); } ProfessorOak.ShowMessage("Could not complete operation:", sbuilder.ToString()); progRing.IsActive = false; progRing.Visibility = Visibility.Collapsed; } catch (Exception ex) { if (ex.InnerException.Message.Contains("server")) { ProfessorOak.ShowMessage("Error", "No connection with the server."); } else { ProfessorOak.ShowMessage("Error", "Could not complete operation."); } } finally { progRing.IsActive = false; progRing.Visibility = Visibility.Collapsed; } }