private async void showTypes(string typeName) { progRing.IsActive = true; progRing.Visibility = Visibility.Visible; TypesRepository t = new TypesRepository(); try { List <Types> types; if (!string.IsNullOrEmpty(typeName)) { types = await t.GetTypesContains(typeName.ToString()); } else { types = await t.GetTypess(); } TypesList.ItemsSource = types.OrderBy(e => e.TypeName); } 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 server."); } else { ProfessorOak.ShowMessage("Error", "Could not complete operation."); } } finally { progRing.IsActive = false; progRing.Visibility = Visibility.Collapsed; } }
private async void PopulateLists() { progRing.IsActive = true; progRing.Visibility = Visibility.Visible; TypesRepository t = new TypesRepository(); RouteRepository r = new RouteRepository(); RegionRepository re = new RegionRepository(); try { List <Types> types = await t.GetTypess(); List <Route> route = await r.GetRoutes(); List <Region> region = await re.GetRegions(); types.Add(new Types { ID = 0, TypeName = " - All Types" }); route.Add(new Route { ID = 0, RouteName = " - All Routes" }); region.Add(new Region { ID = 0, RegionName = " - All Regions" }); App thisApp = Application.Current as App; thisApp.ActiveTypes = types; thisApp.ActiveRoutes = route; thisApp.ActiveRegions = region; } 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("Connection with the server")) { ProfessorOak.ShowMessage("Error", "No connection with server. Ensure you have the proper connections and try again."); } else { ProfessorOak.ShowMessage("Error", "Could not complete operation."); } progRing.IsActive = false; progRing.Visibility = Visibility.Collapsed; } finally { progRing.IsActive = false; progRing.Visibility = Visibility.Collapsed; } }