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"); } }
protected async void OnStart(EventArgs e) { // stuff string Status = "Fail"; string Msg = "Technical Error"; dsTransactions = new F4HApp.dataservice.DSTransactions(); string result = await dsTransactions.GetMemberPoints(App.MemberID); try { RegistrationResponseObject m = JsonConvert.DeserializeObject <RegistrationResponseObject>(result.Replace("[", "").Replace("]", "")); Status = m.Status.ToString(); Msg = m.Msg; } catch { } if (Status == "Success") { await DisplayAlert("Congratulations", "Your registration was successful", "Login"); await Navigation.PushModalAsync(new F4HApp.views.Home()); } else { await DisplayAlert("Food4Health", Msg, "Login"); } // stuff }
private async Task <string> SetMemberPoints() { string result = "Success"; dsTransactions = new F4HApp.dataservice.DSTransactions(); string Response = await dsTransactions.GetMemberPoints(App.MemberID); try { MemberPointsResponseObject m = JsonConvert.DeserializeObject <MemberPointsResponseObject>(Response.Replace("[", "").Replace("]", "")); string Status = m.Status.ToString(); string Msg = m.Msg; int Earned = m.Earned; int Redeemed = m.Redeemed; int Transfered = m.Transfered; Device.BeginInvokeOnMainThread(() => { lblEarnedPoints.Text = Earned.ToString(); lblRedeemPoints.Text = Redeemed.ToString(); lblTransferedPoints.Text = Transfered.ToString(); }); //lblEarnedPoints.Text = Status; } catch (Exception ex) { string rr = ex.Message; } return(result); }
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); }
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"); } }
private async Task <string> GetEarnedTransactionList() { string result = "Success"; dsTransactions = new F4HApp.dataservice.DSTransactions(); string Response = await dsTransactions.EarnPointsList(App.MemberID); try { var tr = JsonConvert.DeserializeObject <List <EarnPointListResponseObject> >(Response); ObservableCollection <EarnPointListResponseObject> trends = new ObservableCollection <EarnPointListResponseObject>(tr); Device.BeginInvokeOnMainThread(() => { LVEarned.ItemsSource = trends; }); } catch (Exception ex) { string rr = ex.Message; } return(result); }
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"); }