private async Task <JToken> validateClub()
        {
            cdReadError myerror   = new cdReadError();
            cdCallAPI   mycallAPI = new cdCallAPI();
            cdQueryAttr qryAcct   = new cdQueryAttr();

            if (CubID.Text != null)
            {
                qryAcct           = new cdQueryAttr();
                qryAcct.ColIndex  = "None";
                qryAcct.IndexName = "None";
                qryAcct.ColName   = "ClubID";
                qryAcct.ColValue  = CubID.Text;
            }
            else if (getClubName.Text != null)
            {
                qryAcct           = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "ClubNameIndex";
                qryAcct.ColName   = "ClubName";
                qryAcct.ColValue  = getClubName.Text;
            }
            else
            {
                await DisplayAlert("Action", "Unable to fetch the club Information ", "Ok");
            }

            getClubs tempClubs = new getClubs();
            var      jsclubs   = await mycallAPI.cdcallClubsGET(qryAcct);

            tempClubs = JsonConvert.DeserializeObject <getClubs>((string)jsclubs);

            System.Diagnostics.Debug.WriteLine(" Club is retrived " + jsclubs);

            if (jsclubs.ToString().Contains("ValidationException") || !jsclubs.ToString().Contains("ClubName"))
            {
                System.Diagnostics.Debug.WriteLine(" Get Clubs Failed " + jsclubs);
                myerror = JsonConvert.DeserializeObject <cdReadError>(jsclubs.ToString());
                await DisplayAlert("Action", "Unable to fetch the club Information ", "Ok");

                return("failed");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(" Get Club Information Successful");
                submitButton.IsEnabled = true;
                assignButton.IsEnabled = true;
                myClub          = tempClubs.Club[0];
                ClubName.Text   = "Club Name: " + tempClubs.Club[0].ClubName;
                CubAddress.Text = "Club Address: " + tempClubs.Club[0].AddressLine1 + " " + tempClubs.Club[0].AddressLine2;
                City.Text       = "City : " + tempClubs.Club[0].City;
                myState.Text    = "State " + tempClubs.Club[0].cdState;
                PostalCode.Text = "Postal Code " + tempClubs.Club[0].PostalCode;

                return("success");
            }
        }
Esempio n. 2
0
        async void getClubs()
        {
            cdQueryAttr qryAcct = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "MemberAccountIDIndex";
            qryAcct.ColName   = "MemberAccountID";
            qryAcct.ColValue  = myAccount.UserName;
            String clubRetrived = "";

            System.Diagnostics.Debug.WriteLine(" Getting clubs from club members");

            getClubMembers myClubMembers = new getClubMembers();
            cdCallAPI      mycallAPI     = new cdCallAPI();

            var jsreponse = await mycallAPI.cdcallClubMembersGET(qryAcct);

            myClubMembers = JsonConvert.DeserializeObject <getClubMembers>((string)jsreponse);

            System.Diagnostics.Debug.WriteLine(" Club Member payload is " + jsreponse);

            try
            {
                foreach (var stacc in myClubMembers.ClubMember)
                {
                    maxarray          = maxarray + 1;
                    qryAcct           = new cdQueryAttr();
                    qryAcct.ColIndex  = "None";
                    qryAcct.IndexName = "None";
                    qryAcct.ColName   = "ClubID";
                    qryAcct.ColValue  = myClubMembers.ClubMember[maxarray].ClubID;

                    System.Diagnostics.Debug.WriteLine(" Populating Club for " + myClubMembers.ClubMember[maxarray].ClubID);

                    getClubs tempClubs = new getClubs();
                    var      jsclubs   = await mycallAPI.cdcallClubsGET(qryAcct);

                    tempClubs    = JsonConvert.DeserializeObject <getClubs>((string)jsclubs);
                    clubRetrived = (string)jsclubs;

                    System.Diagnostics.Debug.WriteLine(" Club is retrived " + jsclubs);

                    System.Diagnostics.Debug.WriteLine(" Before Initializing club " + tempClubs.Club[0].ClubID + "  " + tempClubs.Club[0].ClubName);
                    assignedClubs.Add(tempClubs.Club[0]);
                    System.Diagnostics.Debug.WriteLine(" After Initializing club ");

                    System.Diagnostics.Debug.WriteLine(" Added to assigned clubs ");
                }

                if (clubRetrived.Contains("ClubName"))
                {
                    ClubName.Text   = "Club Name: " + assignedClubs[0].ClubName;
                    ClubID.Text     = "Clud ID: " + assignedClubs[0].ClubID;
                    CubAddress.Text = assignedClubs[0].AddressLine1 + " " + assignedClubs[0].AddressLine2;
                    City.Text       = assignedClubs[0].City;
                    myState.Text    = assignedClubs[0].cdState;
                    PostalCode.Text = assignedClubs[0].PostalCode;
                }
                else
                {
                    PreviousButton.IsEnabled = false;
                    NextButton.IsEnabled     = false;
                    SubmitButton.IsEnabled   = false;
                }

                System.Diagnostics.Debug.WriteLine(" Max Array is " + maxarray);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
                await DisplayAlert("Action", "Unable to fetch data. Please try later.", "OK");
            }
            if (counter == maxarray)
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = false;
            }
            else
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = true;
            }
        }