Ejemplo n.º 1
0
        private async void OnbtnSubmit(object sender, EventArgs e)
        {
            var    ScratchCode = txtScratchCode.Text;
            string Status      = "";
            int    Points      = 0;
            string Msg         = "Technical Problem";

            if (ScratchCode == null)
            {
                await DisplayAlert("Validation Error", "Scratch code cannot be blank", "Re-try");

                return;
            }

            dsTransactions = new F4HApp.dataservice.DSTransactions();
            string result = await dsTransactions.EarnPoints(App.MemberID, ScratchCode);

            EarnResponseObject m = JsonConvert.DeserializeObject <EarnResponseObject>(result.Replace("[", "").Replace("]", ""));

            Status = m.Status.ToString();
            Points = m.Points;
            Msg    = m.Msg;

            if (Status == "Success")
            {
                lblMsg.Text         = "Congratulations you have earned " + Points + " points.";
                lblMsg.IsVisible    = true;
                txtScratchCode.Text = "";
            }
            else
            {
                await DisplayAlert("Validation Error", Msg, "Re-try");
            }
        }
Ejemplo n.º 2
0
        public async void ScanAsync()
        {
            var scanPage = new ZXingScannerPage();

            scanPage.OnScanResult += (result) => {
                // Stop scanning
                scanPage.IsScanning = false;


                // Pop the page and show the result
                Device.BeginInvokeOnMainThread(async() => {
                    await Navigation.PopAsync();
                    var ScratchCode = result.Text;
                    string Status   = "";
                    int Points      = 0;
                    string Msg      = "Technical Problem";

                    if (ScratchCode == null)
                    {
                        await DisplayAlert("Validation Error", "Scratch code cannot be blank", "Re-try");
                        return;
                    }

                    dsTransactions       = new F4HApp.dataservice.DSTransactions();
                    string result2       = await dsTransactions.EarnPoints(App.MemberID, ScratchCode);
                    EarnResponseObject m = JsonConvert.DeserializeObject <EarnResponseObject>(result2.Replace("[", "").Replace("]", ""));
                    Status = m.Status.ToString();
                    Points = m.Points;
                    Msg    = m.Msg;

                    if (Status == "Success")
                    {
                        var msg = "Congratulations you have earned " + Points + " points.";
                        await DisplayAlert("Congratulations", msg, "OK");
                    }
                    else
                    {
                        await DisplayAlert("Validation Error", Msg, "Re-try");
                    }
                    // await DisplayAlert("Scanned Barcode", result.Text, "OK");
                });
            };

            // Navigate to our scanner page
            await Navigation.PushAsync(scanPage);
        }