private async void getVehiclesInfo() { string errorMessage = null; try { string webresponse = await Network.ServiceVehiclesByService(Service.ServiceId); List <ServiceVehicle> rootObject = JsonConvert.DeserializeObject <List <ServiceVehicle> >(webresponse); VehiclesList.Clear(); foreach (ServiceVehicle sv in rootObject) { VehiclesList.Add(sv); } LastUpdate.Text = "Ultima atualização: " + DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"); } catch (Exception ex) { errorMessage = ex.Message; } if (errorMessage != null) { MessageDialog msg = new MessageDialog("Houve algum problema durante a requisição ao servidor. Por favor, verifique se o aparelho está conectado à internet e tente novamente.", "Você está conectado à internet?"); await msg.ShowAsync(); } }
public async Task Init() { search_request1.Username = APIService.Username; var instructors = await _instructorsService.GetAll <List <Instructor> >(search_request1); var instructor = instructors[0]; // Returns logged in instructor InstructorCategorySearchRequest search_request2 = new InstructorCategorySearchRequest(); search_request2.InstructorId = instructor.Id; var instructors_categories = await _instructor_categoriesService.GetAll <List <Instructor_Category> >(search_request2); // Returns all categories of logged in instructor InstructorCategoryCandidateSearchRequest search_request3 = new InstructorCategoryCandidateSearchRequest(); search_request3.PolozenTeorijskiTest = true; search_request3.PolozenTestPrvePomoci = true; search_request3.PolozenPrakticniTest = false; search_request3.Prijavljen = false; search_request3.InstructorId = instructor.Id; foreach (var instructor_category in instructors_categories) { //search_request3.Instructor_CategoryId = instructor_category.Id; search_request3.CategoryId = instructor_category.CategoryId; var instructors_categories_candidates = await _instructor_categories_candidateService.GetAll <List <Instructor_Category_Candidate> >(search_request3); // Returns all users of logged in instructors and all categories of that instructor foreach (var instructor_category_candidate in instructors_categories_candidates) { var candidate = await _candidatesService.GetById <Candidate>(instructor_category_candidate.CandidateId); candidate.category = instructor_category_candidate.Instructor_Category.Category.Name; candidate.candidate_category = candidate.candidate + " " + "(" + candidate.category + ")"; CandidatesList.Add(candidate); } } VehicleSearchRequest vehicle_search_request = new VehicleSearchRequest(); var vehicles = await _vehiclesService.GetAll <List <Vehicle> >(null); foreach (var vehicle in vehicles) { vehicle.vehicle = vehicle.Model.Name + " " + "(" + vehicle.RegistrationNumber + ")"; VehiclesList.Add(vehicle); } }