Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scannerQuiz.OnScanResult += (result) =>
- {
- scannerQuiz.IsScanning = false;
- if (CrossConnectivity.Current.IsConnected)
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- try
- {
- int code = Convert.ToInt32(result.Text);
- if (code > 99 && code < 106)
- {
- var response = await Json_Responses.JSONdownloader.downloader($"{Host.ip}use/{Host.username}/{result.Text}?format=json");
- var permision = JsonConvert.DeserializeObject<JSONpermission>(response.ToString());
- if (permision.can == true)
- {
- var modalPage = new QuizDialog(Convert.ToInt32(result.Text));
- await Navigation.PushModalAsync(modalPage);
- await Navigation.PopAsync();
- scannerQuiz.IsScanning = true;
- }
- else
- {
- await DisplayAlert("Błąd", "Kod już został wcześniej użyty", "ok");
- await Navigation.PopAsync();
- scannerQuiz.IsScanning = true;
- }
- }
- else if (code > 299 && code < 400)
- {
- await DisplayAlert("Informacje", "Aby odczytać ten kod przejdź do kategorii informacje", "ok");
- await Navigation.PopAsync();
- scannerQuiz.IsScanning = true;
- }
- else if (code > 199 && code < 300)
- {
- await DisplayAlert("Informacje", "Aby odczytać ten kod przejdź do kategorii punkty", "ok");
- await Navigation.PopAsync();
- scannerQuiz.IsScanning = true;
- }
- else
- throw new Exception();
- }
- catch
- {
- await DisplayAlert("Błąd", "Zeskanowano kod o złym formacie lub kategorii", "ok");
- await Navigation.PopAsync();
- scannerQuiz.IsScanning = true;
- }
- });
- }
- else
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- await DisplayAlert("Błąd", "Proszę sprawdzić łącze internetowe", "ok");
- await Navigation.PopAsync();
- scannerQuiz.IsScanning = true;
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement