public async Task <JToken> cdcallClubMemberPUT(ClubMembers regacccount) { cdCallAPI mycallAPI = new cdCallAPI(); var response = await mycallAPI.cdCallPutAPI(App.cdClubMemberAPIPutPost, regacccount, App.cdClubMemberKey); return(response); }
private async Task <JToken> createClubMembers(Account regAccount, Club regClub, String assignRole, string parentID) { try { cdReadError myerror = new cdReadError(); cdCallAPI mycallAPI = new cdCallAPI(); ClubMembers myclubmembership = new ClubMembers(); myclubmembership.ClubMemberID = regAccount.UserName + regClub.ClubID; myclubmembership.ClubID = regClub.ClubID; myclubmembership.MemberAccountID = regAccount.UserName; myclubmembership.ClubName = regClub.ClubName; myclubmembership.MemberName = regAccount.FirstName + " " + regAccount.LastName; myclubmembership.MemberRole = assignRole; myclubmembership.Attr1 = parentID; myclubmembership.Attr2 = regAccount.EmailAddress; myclubmembership.Attr3 = "NA"; myclubmembership.Attr4 = "NA"; myclubmembership.Attr5 = "NA"; myclubmembership.Attr6 = "NA"; myclubmembership.Attr7 = "NA"; myclubmembership.Attr8 = "NA"; myclubmembership.Attr9 = "NotApproved"; myclubmembership.Attr10 = "NA"; var jsresponse = await mycallAPI.cdcallClubMemberPUT(myclubmembership); System.Diagnostics.Debug.WriteLine(" Response is " + jsresponse); if (jsresponse.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Club Membership creation call failed " + jsresponse); var myError = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); return("failed"); } else { return("success"); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Unable to create data " + ex); return("failed"); } }
async void cdSubmit(object sender, System.EventArgs e) { System.Diagnostics.Debug.WriteLine(" Clicked Submit Button"); if (ClubName.Text == null || CubAddress.Text == null || City.Text == null || myState.Text == null || PostalCode.Text == null) { await DisplayAlert("Enterable fields cannot be null. ", "Please enter all the fields", "ok"); } else { try { Club thisClub = new Club(); cdCallAPI mycallAPI = new cdCallAPI(); thisClub.ClubName = ClubName.Text; thisClub.AddressLine1 = CubAddress.Text; thisClub.City = City.Text; thisClub.cdState = myState.Text; thisClub.PostalCode = PostalCode.Text; thisClub.ClubID = ClubName.Text.Substring(0, 3) + (Math.Abs(DateTime.Now.ToBinary()).ToString()); myclubCreated = thisClub.ClubID; if (thisClub.AddressLine2 == null) { thisClub.AddressLine2 = "None"; } thisClub.ClubReg = "NA"; thisClub.AddressLine3 = "NA"; thisClub.Attr1 = "NA"; thisClub.Attr2 = "NA"; thisClub.Attr3 = "NA"; thisClub.Attr4 = "NA"; thisClub.Attr5 = "NA"; thisClub.Attr6 = "NA"; thisClub.Attr7 = "NA"; thisClub.Attr8 = "NA"; thisClub.Attr9 = "NA"; thisClub.Attr10 = "NA"; var jsresponse = await mycallAPI.cdcallClubsPUT(thisClub); if (jsresponse.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Club creation call failed " + jsresponse); var myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); createStatus.Text = "Club Creation Failed. " + myerror.message; } else { ClubMembers myclubmembership = new ClubMembers(); myclubmembership.ClubMemberID = myAccount.UserName + ClubName.Text.Substring(0, 3) + (Math.Abs(DateTime.Now.ToBinary()).ToString()); myclubmembership.ClubID = myclubCreated; myclubmembership.MemberAccountID = myAccount.UserName; myclubmembership.ClubName = ClubName.Text; myclubmembership.MemberName = myAccount.FirstName + " " + myAccount.LastName; myclubmembership.MemberRole = "A" + myAccount.Role; myclubmembership.Attr1 = "NA"; myclubmembership.Attr2 = myAccount.EmailAddress; myclubmembership.Attr3 = "NA"; myclubmembership.Attr4 = "NA"; myclubmembership.Attr5 = "NA"; myclubmembership.Attr6 = "NA"; myclubmembership.Attr7 = "NA"; myclubmembership.Attr8 = "NA"; myclubmembership.Attr9 = "Approved"; myclubmembership.Attr10 = "NA"; jsresponse = await mycallAPI.cdcallClubMemberPUT(myclubmembership); if (jsresponse.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Club Membership creation call failed " + jsresponse); var myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); createStatus.Text = "Club Member Creation Failed. " + myerror.message; } else { createStatus.Text = "Registration Successful "; } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("End of Array " + ex); await DisplayAlert("Action", "Unable to fetch data. Please try later.", "OK"); } } }
async void cdSubmit(object sender, System.EventArgs e) { int performSubmit = 0; System.Diagnostics.Debug.WriteLine(" Submit button clicked"); cdCallAPI mycallAPI = new cdCallAPI(); //Populate regiatration data if (regAccount.UserName == null || regAccount.FirstName == null || regAccount.EmailAddress == null || regAccount.LastName == null) { await DisplayAlert("Action", "Key attributes cannot be null. Please go to personal information and enter the same", "Ok"); performSubmit = 0; } else { performSubmit = 1; regAccount.AccountID = regAccount.UserName; regAccount.AccountStatus = "Approved"; if (cdNewClub.IsChecked == true || cdCheckAdmin.IsChecked == true) { regAccount.Role = "A"; } if (cdCheckRider.IsChecked == true) { regAccount.Role = regAccount.Role + "R"; } regAccount.Attr1 = "None"; regAccount.Attr2 = "None"; regAccount.Attr3 = "None"; regAccount.Attr4 = "None"; regAccount.Attr5 = "None"; regAccount.Attr6 = "None"; regAccount.Attr7 = "None"; regAccount.Attr8 = "None"; regAccount.Attr9 = "None"; regAccount.Attr10 = "None"; } if (performSubmit == 1) { var jsresponse = await mycallAPI.cdcallAccountsPUT(regAccount); if (jsresponse.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Account creation call failed " + jsresponse); var myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); cdStatus.Text = "Account Creation Failed because " + myerror.message; await DisplayAlert("Account creation failed", cdStatus.Text, "OK"); } else { signupAccount mysignupAccount = new signupAccount(); mysignupAccount.email = regAccount.EmailAddress; mysignupAccount.username = regAccount.UserName; mysignupAccount.password = regPassword; var signupRespose = await mycallAPI.cdCreateSignup(mysignupAccount); if (signupRespose.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Account signup failed " + jsresponse); var myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); cdStatus.Text = "Login creation failed. " + myerror.message; await DisplayAlert("Login creation failed", cdStatus.Text, "OK"); } else { System.Diagnostics.Debug.WriteLine(" Put API Call Successful"); if (cdNewClub.IsChecked == true) { regClub.ClubName = cdClubName.Text; regClub.ClubID = cdClubName.Text.Substring(0, 3) + (Math.Abs(DateTime.Now.ToBinary()).ToString()); regClub.ClubReg = "NA"; regClub.Attr1 = "NA"; regClub.Attr2 = "NA"; regClub.Attr3 = "NA"; regClub.Attr4 = "NA"; regClub.Attr5 = "NA"; regClub.Attr6 = "NA"; regClub.Attr7 = "NA"; regClub.Attr8 = "NA"; regClub.Attr9 = "Approved"; regClub.Attr10 = "NA"; jsresponse = await mycallAPI.cdcallClubsPUT(regClub); if (jsresponse.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Club creation call failed " + jsresponse); var myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); cdStatus.Text = "Club Creation Failed. " + myerror.message; await DisplayAlert("Club creation failed", cdStatus.Text, "OK"); } else { ClubMembers myclubmembership = new ClubMembers(); myclubmembership.ClubMemberID = regAccount.UserName + regClub.ClubID; myclubmembership.ClubID = regClub.ClubID; myclubmembership.MemberAccountID = regAccount.UserName; myclubmembership.ClubName = regClub.ClubName; myclubmembership.MemberName = regAccount.FirstName + " " + regAccount.LastName; myclubmembership.MemberRole = regAccount.Role; myclubmembership.Attr1 = "NA"; myclubmembership.Attr2 = regAccount.EmailAddress; myclubmembership.Attr3 = "NA"; myclubmembership.Attr4 = "NA"; myclubmembership.Attr5 = "NA"; myclubmembership.Attr6 = "NA"; myclubmembership.Attr7 = "NA"; myclubmembership.Attr8 = "NA"; myclubmembership.Attr9 = "NotApproved"; myclubmembership.Attr10 = "NA"; jsresponse = await mycallAPI.cdcallClubMemberPUT(myclubmembership); if (jsresponse.ToString().Contains("ValidationException")) { System.Diagnostics.Debug.WriteLine(" Club Membership creation call failed " + jsresponse); var myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString()); cdStatus.Text = "Club Member Creation Failed. " + myerror.message; await DisplayAlert("Club Member creation failed", cdStatus.Text, "OK"); } else { await DisplayAlert("Action", "Registration Successful", "Ok"); var bpage = new MainPage(); await Navigation.PushModalAsync(bpage); } } } } } } }