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);
        }
Ejemplo n.º 3
0
        public async void SelectClicked(object sender, EventArgs e)
        {
            var    item            = (Xamarin.Forms.Button)sender;
            string EPointID        = item.CommandParameter.ToString();
            int    AvailablePoints = 0;
            bool   APoints         = int.TryParse(lblAvailPoints.Text, out AvailablePoints);

            dsTransactions = new F4HApp.dataservice.DSTransactions();
            string result = await dsTransactions.RedeemPoints(App.MemberID, EPointID, AvailablePoints);

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

            if (Status == "Success")
            {
                await SetMemberPoints();
                await DisplayAlert("Food4Health", "Congratulations! Points redeemed successfully", "Done");
            }
            else
            {
                await DisplayAlert("Food4Health", Msg, "Done");
            }
        }
Ejemplo n.º 4
0
        private async void btnTransfer_Clicked(object sender, EventArgs e)
        {
            int  SelectedCount   = obj.Count;
            int  AvailablePoints = 0;
            bool AP                 = int.TryParse(lblAvailPoints.Text, out AvailablePoints);
            int  TransferPoints     = 0;
            bool TP                 = int.TryParse(txtPoints.Text, out TransferPoints);
            int  TotalTransferPoint = SelectedCount * TransferPoints;

            if (AvailablePoints < TotalTransferPoint)
            {
                await DisplayAlert("Validation Error", "Sorry you donot have enough points to transfer", "Re-try");

                return;
            }

            if (TransferPoints == 0)
            {
                await DisplayAlert("Validation Error", "Please enter points to transfer", "Re-try");

                return;
            }


            if (SelectedCount == 0)
            {
                await DisplayAlert("Validation Error", "Please select atleast one member from the list", "Re-try");

                return;
            }

            foreach (var items in obj)
            {
                var MemberID = items.FFMemberID;

                string Status = "Fail";
                string Msg    = "Technical Error";
                int    Points = 0;

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

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

                //string Message = @"You have received 10 loyalty points in your F4H app sent by member - " + App.MobileNumber + ".Please show members list only in Transfer Points.";

                //string SMSResult = await dsLogin.SendSms(items., Message);
                //SMSResponceObject S = JsonConvert.DeserializeObject<SMSResponceObject>(SMSResult.Replace("[", "").Replace("]", ""));

                //string SmsStatusAlert = S.Status.ToString();



                //if (Status == "Success")
                //{

                //}
                //else
                //{
                //    await DisplayAlert("Validation Error", Msg, "Re-try");
                //}
            }

            await SetMemberPoints();

            await DisplayAlert("Food4Health", "Points Transfer done", "Done");
        }