Beispiel #1
0
        public async Task <JToken> cdcallClubsGET(cdQueryAttr QueryObject)
        {
            cdCallAPI mycallAPI      = new cdCallAPI();
            var       getClubMembers = await mycallAPI.cdCallGetAPI(App.cdClubAPIGet, QueryObject, App.cdClubKey);

            return(getClubMembers);
        }
        async void cdTrack(object sender, System.EventArgs e)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine(" Clicked Track Button");
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "StudentIDindex";
                qryAcct.ColName   = "StudentID";
                qryAcct.ColValue  = mystudAccounts.Account[counter].UserName;

                getDriver        myDriverArray = new getDriver();
                DriverAllocation pubDriverInfo = new DriverAllocation();
                cdCallAPI        mycallAPI     = new cdCallAPI();

                var jsreponse = await mycallAPI.cdcallDriverAllocGET(qryAcct);

                myDriverArray = JsonConvert.DeserializeObject <getDriver>((string)jsreponse);

                pubDriverInfo = myDriverArray.DriverAllocation[0];

                String trackkey = pubDriverInfo.DriverID + DateTime.Now.ToShortDateString();
                System.Diagnostics.Debug.WriteLine(" Tracking " + mystudAccounts.Account[counter].UserName + "with the key " + trackkey);

                var tpage = new cdTrackRiders(trackkey, loginAccount);
                await Navigation.PushModalAsync(tpage);
            }
            catch (Exception ex)
            {
                await DisplayAlert("No Tracking", "No Tracking information available for this student", "OK");

                System.Diagnostics.Debug.WriteLine("Exception is " + ex);
            }
        }
Beispiel #3
0
        public async Task <JToken> cdcallDriverAllocGET(cdQueryAttr QueryObject)
        {
            cdCallAPI mycallAPI      = new cdCallAPI();
            var       getDriverAlloc = await mycallAPI.cdCallGetAPI(App.cdDriverAllocURLGet, QueryObject, App.cdDriverAllocationKey);

            return(getDriverAlloc);
        }
Beispiel #4
0
        public async Task <JToken> cdcallTrackLocGET(cdQueryAttr QueryObject)
        {
            cdCallAPI mycallAPI   = new cdCallAPI();
            var       getAccounts = await mycallAPI.cdCallGetAPI(App.cdTrackLocGet, QueryObject, App.cdDriverLocationKey);

            return(getAccounts);
        }
Beispiel #5
0
        async void cdAssign(object sender, System.EventArgs e)
        {
            try
            {
                if (myAccount.Role.Contains("R") & myAccount.ParentID != "None")
                {
                    Account     paccount  = new Account();
                    cdCallAPI   mycallAPI = new cdCallAPI();
                    cdQueryAttr qryAcct   = new cdQueryAttr();
                    qryAcct.ColIndex  = "IndexName";
                    qryAcct.IndexName = "UserNameindex";
                    qryAcct.ColName   = "UserName";
                    qryAcct.ColValue  = myAccount.ParentID;

                    getAccounts myAccountsArray = new getAccounts();

                    var jsreponse = await mycallAPI.cdcallAccountsGET(qryAcct);

                    myAccountsArray = JsonConvert.DeserializeObject <getAccounts>((string)jsreponse);
                    paccount        = myAccountsArray.Account[0];
                    var tpage = new cdAssignClubs(paccount, myAccount);
                    await Navigation.PushModalAsync(tpage);
                }
                else
                {
                    var tpage = new cdAssignClubs(myAccount, myAccount);
                    await Navigation.PushModalAsync(tpage);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
                await DisplayAlert("Action", "Unable to fetch data. Please try later.", "OK");
            }
        }
Beispiel #6
0
        // This is the generic Get API call
        public async Task <JToken> cdCallGetAPI(string callingapiurl, cdQueryAttr qobj, String accessKey)
        {
            var        uri    = new Uri(callingapiurl);
            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
            client.DefaultRequestHeaders.TryAddWithoutValidation("IndexName", qobj.ColIndex);
            client.DefaultRequestHeaders.TryAddWithoutValidation("ColIndex", qobj.IndexName);
            client.DefaultRequestHeaders.TryAddWithoutValidation("ColName", qobj.ColName);
            client.DefaultRequestHeaders.TryAddWithoutValidation(qobj.ColName, qobj.ColValue);
            client.DefaultRequestHeaders.TryAddWithoutValidation("x-api-key", accessKey);

            System.Diagnostics.Debug.WriteLine(" Request passed is " + qobj.IndexName + qobj.ColName + " " + qobj.ColValue);

            var response = await client.GetAsync(uri);

            var responseJSON = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                System.Diagnostics.Debug.WriteLine(" Get API Call Successful");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(" Get API Call failed " + response.ReasonPhrase);
            }

            return(responseJSON);
        }
        async void callGetDriver(Account logAccount)
        {
            try
            {
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "StudentIDindex";
                qryAcct.ColName   = "StudentID";
                qryAcct.ColValue  = logAccount.UserName;

                getDriver        myDriverArray = new getDriver();
                DriverAllocation pubDriverInfo = new DriverAllocation();
                cdCallAPI        mycallAPI     = new cdCallAPI();

                var jsreponse = await mycallAPI.cdcallDriverAllocGET(qryAcct);

                myDriverArray = JsonConvert.DeserializeObject <getDriver>((string)jsreponse);

                pubDriverInfo = myDriverArray.DriverAllocation[0];

                DriverName.Text          = "Driver Name: " + pubDriverInfo.DriverName;
                CarType.Text             = "Car Type: " + pubDriverInfo.Attr3;
                LicensePlate.Text        = "License Plate: " + pubDriverInfo.Attr4;
                DestinationAddress.Text  = "Address: " + pubDriverInfo.Attr1;
                DestinationAddress2.Text = "               " + pubDriverInfo.Attr2;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Clubs Loop " + ex);
                await DisplayAlert("Action", "Update Status Failed", "OK");
            }
        }
Beispiel #8
0
        // Function to get Accounts
        public async Task <JToken> cdcallAccountsGET(cdQueryAttr QueryObject)
        {
            cdCallAPI mycallAPI    = new cdCallAPI();
            var       getLocations = await mycallAPI.cdCallGetAPI(App.cdAccountAPIGetGlobal, QueryObject, App.cdAccountKey);

            return(getLocations);
        }
Beispiel #9
0
        public async Task <JToken> cdcallEventsGET(cdQueryAttr QueryObject)
        {
            cdCallAPI mycallAPI = new cdCallAPI();
            var       response  = await mycallAPI.cdCallGetAPI(App.cdEventAPIGet, QueryObject, App.cdEventKey);

            return(response);
        }
        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");
            }
        }
        async void getStudentData(Account logAccount)
        {
            //Getting Student Information
            try
            {
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "DriverIDAllocationIDindex";
                qryAcct.ColName   = "DriverID";
                qryAcct.ColValue  = logAccount.UserName;
                counter           = 0;

                getDriver        myStudentArray = new getDriver();
                DriverAllocation pubStudentInfo = new DriverAllocation();
                cdCallAPI        mycallAPI      = new cdCallAPI();

                var jsreponse = await mycallAPI.cdcallDriverAllocGET(qryAcct);

                myStudentArray = JsonConvert.DeserializeObject <getDriver>((string)jsreponse);
                mystudArray    = myStudentArray;

                System.Diagnostics.Debug.WriteLine("Get response for students is " + jsreponse);
                try {
                    foreach (var dalloc in myStudentArray.DriverAllocation)
                    {
                        maxarray = maxarray + 1;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("End of Array " + ex);
                }

                System.Diagnostics.Debug.WriteLine("Assigning student name. Max array " + maxarray);

                StudentName.Text         = "Student Name: " + mystudArray.DriverAllocation[counter].StudentName;
                DestinationAddress.Text  = "Destination Address : " + mystudArray.DriverAllocation[counter].Attr1;
                DestinationAddress2.Text = "                       " + mystudArray.DriverAllocation[counter].Attr2;
                System.Diagnostics.Debug.WriteLine("Assigned dest address ");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
                await DisplayAlert("No Student Allocation Found", "No Student Allocation Found " + ex, "ok");
            }
            if (counter >= maxarray)
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = false;
            }
            else
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = true;
            }
        }
        async void getStudentInfo(Account logAccount)
        {
            cdQueryAttr qryAcct = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "ParentIDindex";
            qryAcct.ColName   = "ParentID";
            qryAcct.ColValue  = logAccount.UserName;

            getAccounts myStudentArray = new getAccounts();
            cdCallAPI   mycallAPI      = new cdCallAPI();

            var jsreponse = await mycallAPI.cdcallAccountsGET(qryAcct);

            myStudentArray = JsonConvert.DeserializeObject <getAccounts>((string)jsreponse);
            mystudAccounts = myStudentArray;

            try
            {
                foreach (var stacc in myStudentArray.Account)
                {
                    maxarray = maxarray + 1;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
            }

            UserName.Text     = "User Name: " + mystudAccounts.Account[0].UserName;
            cdEmail.Text      = mystudAccounts.Account[0].EmailAddress;
            cdFirstName.Text  = mystudAccounts.Account[0].FirstName;
            cdMiddleName.Text = mystudAccounts.Account[0].MiddleName;
            cdLastName.Text   = mystudAccounts.Account[0].LastName;
            cdAddress1.Text   = mystudAccounts.Account[0].AddressLine1;
            cdAddress2.Text   = mystudAccounts.Account[0].AddressLine2;
            cdCity.Text       = mystudAccounts.Account[0].City;
            cdState.Text      = mystudAccounts.Account[0].cdState;
            cdPostalCode.Text = mystudAccounts.Account[0].PostalCode;
            cdPhone.Text      = mystudAccounts.Account[0].Phone;

            System.Diagnostics.Debug.WriteLine(" Max Array is " + maxarray);

            if (counter == maxarray)
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = false;
            }
            else
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = true;
            }
        }
Beispiel #13
0
        public async Task <JToken> cdcallEmailPUT(String EventID, String EventName, String myClubID, String ClubName, String EventDate)
        {
            const String emailcount = "3";
            String       consEmails = "";
            cdEmails     eventEmail = new cdEmails();

            eventEmail.EmailID      = EventID;
            eventEmail.EmailCount   = emailcount;
            eventEmail.EventName    = EventName;
            eventEmail.ClubName     = ClubName;
            eventEmail.Attr1        = EventDate;
            eventEmail.Attr2        = "None";
            eventEmail.Attr3        = "None";
            eventEmail.Attr4        = "None";
            eventEmail.Attr5        = "None";
            eventEmail.Attr6        = "None";
            eventEmail.Attr7        = "None";
            eventEmail.Attr8        = "None";
            eventEmail.Attr9        = "None";
            eventEmail.Attr10       = "None";
            eventEmail.EmailSubject = "Signup for new event - " + EventName;
            eventEmail.EmailBody    = "Please sign up for a new event " + EventName + " on " + EventDate + " , of your " + ClubName + " by logging on to clubhives App";
            cdCallAPI      mycallAPI = new cdCallAPI();
            cdQueryAttr    qryAcct   = new cdQueryAttr();
            getClubMembers cdcm      = new getClubMembers();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "ClubIDIndex";
            qryAcct.ColName   = "ClubID";
            qryAcct.ColValue  = myClubID;
            var jsreponse = await mycallAPI.cdcallAccountsGET(qryAcct);

            cdcm = JsonConvert.DeserializeObject <getClubMembers>((string)jsreponse);
            int counter = 0;

            foreach (var stacc in cdcm.ClubMember)
            {
                if (counter == 0)
                {
                    consEmails = stacc.Attr2;
                    counter    = counter + 1;
                }
                else
                {
                    consEmails = consEmails + " | " + stacc.Attr2;
                }
            }

            eventEmail.EmailAddress = consEmails;

            var response = await mycallAPI.cdCallPutAPI(App.cdEmailAPIPutPost, eventEmail, App.cdClubMemberKey);

            return(response);
        }
        async void cdFind(object sender, System.EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(" Clicked Find Button");
            String      myrole    = " ";
            cdCallAPI   mycallAPI = new cdCallAPI();
            Account     myaccount = new Account();
            cdQueryAttr qryAcct   = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "MemberAccountIDIndex";
            qryAcct.ColName   = "MemberAccountID";
            // qryAcct.ColValue = EmailAddress.Text;
            counter = 0;

            try
            {
                getClubMembers myAccountsArray = new getClubMembers();

                var jsreponse = await mycallAPI.cdcallClubMembersGET(qryAcct);

                myAccountsArray = JsonConvert.DeserializeObject <getClubMembers>((string)jsreponse);
                //   ApplicantName.Text = "Applicant Name: " + myAccountsArray.ClubMember[counter].MemberName;

                if (myAccountsArray.ClubMember[counter].MemberRole.Contains("D"))
                {
                    myrole = myrole + " Driver ";
                }
                if (myAccountsArray.ClubMember[counter].MemberRole.Contains("P"))
                {
                    myrole = myrole + " Parent ";
                }
                if (myAccountsArray.ClubMember[counter].MemberRole.Contains("A"))
                {
                    myrole = myrole + " Admin ";
                }
                if (unClubMembers[counter].MemberRole.Contains("R"))
                {
                    myrole = myrole + " Rider ";
                }

                //  ApplicantType.Text = "Applicant Role: " + myrole;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Unable to fetch data " + ex);
                await DisplayAlert("Unable to fetch data", "Unable to fetch data", "OK");
            }
            //PreviousButton.IsEnabled = false;
            //NextButton.IsEnabled = false;
        }
        async void getStudentInfo(Account logAccount)
        {
            cdQueryAttr qryAcct = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "ParentIDindex";
            qryAcct.ColName   = "ParentID";
            qryAcct.ColValue  = logAccount.UserName;

            cdCallAPI mycallAPI = new cdCallAPI();

            try
            {
                var jsreponse = await mycallAPI.cdcallAccountsGET(qryAcct);

                myStudentArray = JsonConvert.DeserializeObject <getAccounts>((string)jsreponse);

                foreach (var stacc in myStudentArray.Account)
                {
                    maxarray = maxarray + 1;
                }
                UserName.Text           = "User Name: " + myStudentArray.Account[0].FirstName + " " + myStudentArray.Account[0].LastName;
                cdEmail.Text            = "Email Address: " + myStudentArray.Account[0].EmailAddress;
                cdFirstName.Text        = "First Name: " + myStudentArray.Account[0].FirstName;
                cdMiddleName.Text       = "Middle Name: " + myStudentArray.Account[0].MiddleName;
                cdLastName.Text         = "Last Name: " + myStudentArray.Account[0].LastName;
                cdSignupRider.IsChecked = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
            }

            System.Diagnostics.Debug.WriteLine(" Max Array is " + maxarray);

            if (counter == maxarray)
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = false;
            }
            else
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = true;
            }
        }
Beispiel #16
0
        async void getPickerClubInfo()
        {
            cdQueryAttr qryAcct = new cdQueryAttr();

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

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

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

            try
            {
                var jsreponse = await mycallAPI.cdcallClubMembersGET(qryAcct);

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

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

                foreach (var stacc in myClubMembers.ClubMember)
                {
                    maxarray = maxarray + 1;
                    if (myClubMembers.ClubMember[maxarray].MemberRole.Contains("A") == true)
                    {
                        picker.Items.Add(myClubMembers.ClubMember[maxarray].ClubName + "|" + myClubMembers.ClubMember[maxarray].ClubID);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
            }
        }
Beispiel #17
0
        async Task <JToken> cdMapStdDrv(String myCurrentEventID)
        {
            List <EventSignup> drveventsignups  = new List <EventSignup>();
            List <EventSignup> stdeventsignups  = new List <EventSignup>();
            cdAllEventSignups  curreventsignups = new cdAllEventSignups();

            cdCallAPI            mycallAPI = new cdCallAPI();
            cdUpdateEventMembers updem     = new cdUpdateEventMembers();
            cdQueryAttr          qryAcct   = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "EventIDIndex";
            qryAcct.ColName   = "EventID";
            qryAcct.ColValue  = myCurrentEventID;
            int esmaxarray = -1;
            int drvarray   = -1;
            int stdarray   = -1;

            var response = await mycallAPI.cdcallEventMembersGET(qryAcct);

            curreventsignups = JsonConvert.DeserializeObject <cdAllEventSignups>((string)response);

            System.Diagnostics.Debug.WriteLine(" Event Signup payload is " + response);

            try
            {
                foreach (var divsignup in curreventsignups.EventSignup)
                {
                    esmaxarray = esmaxarray + 1;
                    try
                    {
                        if (divsignup.MemberRole.Contains("D") == true)
                        {
                            System.Diagnostics.Debug.WriteLine("Adding Driver " + divsignup.MemberAccountID);
                            drvarray = drvarray + 1;
                            drveventsignups.Add(divsignup);
                            System.Diagnostics.Debug.WriteLine("Added Driver " + divsignup.MemberAccountID);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Adding Student " + divsignup.MemberAccountID);
                            stdarray = stdarray + 1;
                            stdeventsignups.Add(divsignup);
                            System.Diagnostics.Debug.WriteLine("Added Student " + divsignup.MemberAccountID);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Out of loop " + ex);
                    }
                }

                System.Diagnostics.Debug.WriteLine(" Event signups devided. Max array is " + esmaxarray);
                int stdcounter = 0;

                foreach (var allsignup in drveventsignups)
                {
                    int rcount = Convert.ToInt32(allsignup.RiderCount);
                    try
                    {
                        for (stdcounter = 0; stdcounter <= stdarray && rcount > 0; stdcounter++)
                        {
                            rcount = rcount - 1;
                            //Do student driver allocation
                            DriverAllocation myDriverAlloc = new DriverAllocation();
                            myDriverAlloc.AllocationID = allsignup.MemberAccountID + stdeventsignups[stdcounter].MemberAccountID + myCurrentEventID;
                            myDriverAlloc.EventID      = myCurrentEventID;
                            myDriverAlloc.ClubID       = allsignup.ClubID;
                            myDriverAlloc.DriverID     = allsignup.MemberAccountID;
                            myDriverAlloc.StudentID    = stdeventsignups[stdcounter].MemberAccountID;
                            myDriverAlloc.EventName    = allsignup.EventName;
                            myDriverAlloc.ClubName     = allsignup.ClubName;
                            myDriverAlloc.StudentName  = stdeventsignups[stdcounter].MemberName;
                            myDriverAlloc.DriverName   = allsignup.MemberName;
                            myDriverAlloc.Attr1        = allsignup.Attr1;
                            myDriverAlloc.Attr2        = allsignup.Attr2;
                            myDriverAlloc.Attr3        = allsignup.Attr3;
                            myDriverAlloc.Attr4        = allsignup.Attr4;
                            myDriverAlloc.Attr5        = "None";
                            myDriverAlloc.Attr6        = "None";
                            myDriverAlloc.Attr7        = "None";
                            myDriverAlloc.Attr8        = "None";
                            myDriverAlloc.Attr9        = "None";
                            myDriverAlloc.Attr10       = "None";

                            var daresponse = await mycallAPI.cdcallDriverAllocPUT(myDriverAlloc);

                            if (daresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Put API Call failed " + daresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Put API Call Successful ");
                            }

                            //Set Student to Allocated
                            updem.EventMemberID = stdeventsignups[stdcounter].EventMemberID;
                            updem.ColumnName    = "AllocationStatus";
                            updem.ColumnValue   = "ALLOCATED";
                            updem.ColumnName1   = "RiderCount";
                            updem.ColumnValue1  = "0";
                            updem.ColumnName2   = "Attr1";
                            updem.ColumnValue2  = "None";
                            updem.ColumnName3   = "Attr2";
                            updem.ColumnValue3  = "None";
                            updem.ColumnName4   = "Attr3";
                            updem.ColumnValue4  = "None";

                            daresponse = await mycallAPI.cdEventMembersPOST(updem);

                            if (daresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call failed " + daresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call Successful  ");
                            }
                        }

                        if (rcount <= 0)
                        {
                            //Set driver to allocated
                            updem.EventMemberID = allsignup.EventMemberID;
                            updem.ColumnName    = "AllocationStatus";
                            updem.ColumnValue   = "ALLOCATED";
                            updem.ColumnName1   = "RiderCount";
                            updem.ColumnValue1  = "0";
                            updem.ColumnName2   = "Attr1";
                            updem.ColumnValue2  = "None";
                            updem.ColumnName3   = "Attr2";
                            updem.ColumnValue3  = "None";
                            updem.ColumnName4   = "Attr3";
                            updem.ColumnValue4  = "None";

                            var dauresponse = await mycallAPI.cdEventMembersPOST(updem);

                            if (dauresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call failed " + dauresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call Successful ");
                            }
                        }
                        else
                        {
                            updem.EventMemberID = allsignup.EventMemberID;
                            updem.ColumnName    = "AllocationStatus";
                            updem.ColumnValue   = "UNALLOCATED";
                            updem.ColumnName1   = "RiderCount";
                            updem.ColumnValue1  = rcount.ToString();
                            updem.ColumnName2   = "Attr1";
                            updem.ColumnValue2  = "None";
                            updem.ColumnName3   = "Attr2";
                            updem.ColumnValue3  = "None";
                            updem.ColumnName4   = "Attr3";
                            updem.ColumnValue4  = "None";

                            var dauresponse = await mycallAPI.cdEventMembersPOST(updem);

                            if (dauresponse.ToString().Contains("ValidationException"))
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call failed " + dauresponse);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" Post API Call Successful ");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Out of loop " + ex);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Loop " + ex);
            }

            return("success");
        }
Beispiel #18
0
        async Task <JToken> createEventSignups(String fwho)
        {
            if (fwho == "Self")
            {
                cdCallAPI      mycallAPI          = new cdCallAPI();
                cdReadError    myerror            = new cdReadError();
                cdEventSignups insertEventMembers = new cdEventSignups();
                insertEventMembers.EventID          = assignedEvents[counter].EventID;
                insertEventMembers.EventName        = assignedEvents[counter].EventName;
                insertEventMembers.ClubName         = assignedEvents[counter].ClubName;
                insertEventMembers.ClubID           = assignedEvents[counter].ClubID;
                insertEventMembers.AllocationStatus = "UNALLOCATED";
                insertEventMembers.DriverCar        = CarType.Text;
                insertEventMembers.RiderCount       = CarAllowance.Text;
                insertEventMembers.PickupLocation   = assignedEvents[counter].AddressLine1 + " " + assignedEvents[counter].City + " " + assignedEvents[counter].cdState + " " + assignedEvents[counter].PostalCode;
                insertEventMembers.Attr1            = assignedEvents[counter].AddressLine1 + " " + assignedEvents[counter].AddressLine2;
                insertEventMembers.Attr2            = assignedEvents[counter].City + " " + assignedEvents[counter].cdState + " " + assignedEvents[counter].PostalCode;
                insertEventMembers.Attr3            = "None";
                insertEventMembers.Attr4            = "None";
                insertEventMembers.Attr5            = "None";
                insertEventMembers.Attr6            = "None";
                insertEventMembers.Attr7            = "None";
                insertEventMembers.Attr8            = "None";
                insertEventMembers.Attr9            = "None";
                insertEventMembers.Attr10           = "None";
                insertEventMembers.EventMemberID    = myAccount.UserName + assignedEvents[counter].ClubName.Substring(0, 3) + assignedEvents[counter].EventName.Substring(0, 3) + (Math.Abs(DateTime.Now.ToBinary()).ToString());
                insertEventMembers.MemberName       = myAccount.FirstName + " " + myAccount.LastName;
                insertEventMembers.MemberAccountID  = myAccount.UserName;
                if (cdCheckRider.IsChecked == true)
                {
                    insertEventMembers.MemberRole = "D";
                    insertEventMembers.Attr3      = CarType.Text;
                    insertEventMembers.Attr4      = CarLicense.Text;
                }
                else
                {
                    insertEventMembers.MemberRole = "R";
                }
                var jsresponse = await mycallAPI.cdcallEventsMemberPUT(insertEventMembers);

                if (jsresponse.ToString().Contains("ValidationException"))
                {
                    System.Diagnostics.Debug.WriteLine(" Put API Call failed " + jsresponse);
                    myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString());
                    await DisplayAlert("Event Signup Failed", jsresponse.ToString(), "ok");

                    return("failed");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(" Put API Call Successful");
                    await DisplayAlert("Event Signup Successful", "Event Signup Successful", "ok");

                    return("success");
                }
            }
            else
            {
                cdQueryAttr qryAcct = new cdQueryAttr();
                qryAcct.ColIndex  = "IndexName";
                qryAcct.IndexName = "ParentIDIndex";
                qryAcct.ColName   = "Attr1";
                qryAcct.ColValue  = myAccount.UserName;

                System.Diagnostics.Debug.WriteLine(" Getting Students from login user");

                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)
                    {
                        cdCallAPI      myscallAPI         = new cdCallAPI();
                        cdReadError    myerror            = new cdReadError();
                        cdEventSignups insertEventMembers = new cdEventSignups();
                        insertEventMembers.EventID          = assignedEvents[counter].EventID;
                        insertEventMembers.EventName        = assignedEvents[counter].EventName;
                        insertEventMembers.ClubName         = assignedEvents[counter].ClubName;
                        insertEventMembers.ClubID           = assignedEvents[counter].ClubID;
                        insertEventMembers.AllocationStatus = "UNALLOCATED";
                        insertEventMembers.DriverCar        = "NA";
                        insertEventMembers.RiderCount       = "0";
                        insertEventMembers.PickupLocation   = assignedEvents[counter].AddressLine1 + " " + assignedEvents[counter].City + " " + assignedEvents[counter].cdState + " " + assignedEvents[counter].PostalCode;
                        insertEventMembers.Attr1            = assignedEvents[counter].AddressLine1 + " " + assignedEvents[counter].AddressLine2;
                        insertEventMembers.Attr2            = assignedEvents[counter].City + " " + assignedEvents[counter].cdState + " " + assignedEvents[counter].PostalCode;
                        insertEventMembers.Attr3            = "None";
                        insertEventMembers.Attr4            = "None";
                        insertEventMembers.Attr5            = "None";
                        insertEventMembers.Attr6            = "None";
                        insertEventMembers.Attr7            = "None";
                        insertEventMembers.Attr8            = "None";
                        insertEventMembers.Attr9            = "None";
                        insertEventMembers.Attr10           = "None";
                        insertEventMembers.EventMemberID    = stacc.MemberAccountID + stacc.ClubName.Substring(0, 3) + assignedEvents[counter].EventName.Substring(0, 3) + (Math.Abs(DateTime.Now.ToBinary()).ToString());
                        insertEventMembers.MemberName       = stacc.MemberName;
                        insertEventMembers.MemberRole       = "R";
                        var jsresponse = await myscallAPI.cdcallEventsMemberPUT(insertEventMembers);

                        if (jsresponse.ToString().Contains("ValidationException"))
                        {
                            System.Diagnostics.Debug.WriteLine(" Put API Call failed " + jsresponse);
                            myerror = JsonConvert.DeserializeObject <cdReadError>(jsresponse.ToString());
                            await DisplayAlert("Create Event Members", "Unable to create event members", "ok");

                            returnError = returnError + " " + stacc.MemberName;
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine(" Put API Call Successful for " + stacc.MemberName);
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("End of Clubs Loop " + ex);
                }

                System.Diagnostics.Debug.WriteLine(" Looped through all students assigned to the club ");
                if (returnError == "NA")
                {
                    await DisplayAlert("Event Signup Successful", "Event Signup Successful for all members", "ok");

                    return("success");
                }
                else
                {
                    await DisplayAlert("Event Signup Failed", "Event Signup failed for " + returnError + ". Sign up individual members", "ok");

                    return("failed for " + returnError);
                }
            }
        }
Beispiel #19
0
        async void getEvents()
        {
            cdQueryAttr qryAcct = new cdQueryAttr();

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

            System.Diagnostics.Debug.WriteLine(" Getting Clubs from login user");

            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.ColIndex  = "IndexName";
                    qryAcct.IndexName = "ClubIDIndex";
                    qryAcct.ColName   = "ClubID";
                    qryAcct.ColValue  = stacc.ClubID;

                    if (prevclub == stacc.ClubID)
                    {
                        prevclub = stacc.ClubID;
                    }
                    else
                    {
                        try
                        {
                            getEvents myTempEvents = new getEvents();

                            var jsereponse = await mycallAPI.cdcallEventsGET(qryAcct);

                            myTempEvents = JsonConvert.DeserializeObject <getEvents>((string)jsereponse);
                            System.Diagnostics.Debug.WriteLine(" response pay load is " + jsereponse);

                            foreach (var mte in myTempEvents.cdEvents)
                            {
                                System.Diagnostics.Debug.WriteLine(" Event counter is " + eventcounter);
                                mte.Attr1 = stacc.MemberRole;
                                assignedEvents.Add(mte);
                                eventcounter = eventcounter + 1;
                            }
                        }
                        catch (Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine("No events for this club " + stacc.ClubID + " " + ex);
                        }

                        System.Diagnostics.Debug.WriteLine(" Events added ");
                        prevclub = stacc.ClubID;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Clubs Loop " + ex);
            }



            System.Diagnostics.Debug.WriteLine("Populating global strings ");

            myClubName     = assignedEvents[0].ClubName;
            myClubID       = assignedEvents[0].ClubID;
            myEventID      = assignedEvents[0].EventID;
            myEventName    = assignedEvents[0].EventName;
            myEventAddress = assignedEvents[0].AddressLine1 + " " + assignedEvents[0].AddressLine2 + " ," + assignedEvents[0].City + " ," + assignedEvents[0].cdState + " " + assignedEvents[0].PostalCode;

            System.Diagnostics.Debug.WriteLine("Populating event fields ");

            EventName.Text    = "Event Name: " + assignedEvents[0].EventName;
            EventID.Text      = "Event ID: " + assignedEvents[0].EventID;
            EventAddress.Text = assignedEvents[0].AddressLine1;
            if (assignedEvents[0].AddressLine2 == "None" || assignedEvents[0].AddressLine2 == "NA")
            {
                EventAddress2.Text = "";
            }
            else
            {
                EventAddress2.Text = assignedEvents[0].AddressLine2;
            }
            City.Text            = assignedEvents[0].City;
            myState.Text         = assignedEvents[0].cdState;
            PostalCode.Text      = assignedEvents[0].PostalCode;
            ClubName.Text        = assignedEvents[0].ClubName;
            cdNotes.Text         = assignedEvents[0].Notes;
            eventDatePicker.Date = Convert.ToDateTime(assignedEvents[0].EventDate);

            maxarray = eventcounter - 1;
            System.Diagnostics.Debug.WriteLine(" Max Array is " + maxarray);

            if (assignedEvents[0].Attr1.Contains("A") == false)
            {
                EventName.IsEnabled       = false;
                EventID.IsEnabled         = false;
                EventAddress.IsEnabled    = false;
                EventAddress2.IsEnabled   = false;
                City.IsEnabled            = false;
                myState.IsEnabled         = false;
                PostalCode.IsEnabled      = false;
                cdNotes.IsEnabled         = false;
                eventDatePicker.IsEnabled = false;
            }
            else
            {
                EventName.IsEnabled       = true;
                EventID.IsEnabled         = true;
                EventAddress.IsEnabled    = true;
                EventAddress2.IsEnabled   = true;
                City.IsEnabled            = true;
                myState.IsEnabled         = true;
                PostalCode.IsEnabled      = true;
                cdNotes.IsEnabled         = true;
                eventDatePicker.IsEnabled = true;
            }

            if (counter == maxarray)
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = false;
            }
            else
            {
                PreviousButton.IsEnabled = false;
                NextButton.IsEnabled     = true;
            }
        }
        async void cdqueryAll()
        {
            String      myrole    = " ";
            int         clubUACM  = 0;
            cdCallAPI   mycallAPI = new cdCallAPI();
            Account     myaccount = new Account();
            cdQueryAttr qryAcct   = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "MemberAccountIDIndex";
            qryAcct.ColName   = "MemberAccountID";
            qryAcct.ColValue  = loginAccount.AccountID;

            getClubMembers myClubs             = new getClubMembers();
            getClubMembers myUnApprovedMembers = new getClubMembers();

            var jsreponse = await mycallAPI.cdcallClubMembersGET(qryAcct);

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

            System.Diagnostics.Debug.WriteLine("Getting Clubs. Response received is " + jsreponse);

            try
            {
                foreach (var myc in myClubs.ClubMember)
                {
                    if (myc.MemberRole.Contains("A"))
                    {
                        cdQueryAttr qryAcctUACM = new cdQueryAttr();
                        qryAcctUACM.ColIndex  = "IndexName";
                        qryAcctUACM.IndexName = "AccountStatusIndex";
                        qryAcctUACM.ColName   = "ClubID";
                        qryAcctUACM.ColValue  = myc.ClubID;

                        System.Diagnostics.Debug.WriteLine("Getting unapproved members for Club ID " + myc.ClubID);

                        var jsreponseUACM = await mycallAPI.cdcallClubMembersUAGET(qryAcctUACM);

                        myUnApprovedMembers = JsonConvert.DeserializeObject <getClubMembers>((string)jsreponseUACM);

                        System.Diagnostics.Debug.WriteLine("Getting Unapproved club members. Response received is " + jsreponseUACM);

                        foreach (var mycuam in myUnApprovedMembers.ClubMember)
                        {
                            System.Diagnostics.Debug.WriteLine("Adding Club Member to the list " + mycuam.MemberAccountID);
                            unClubMembers.Add(mycuam);
                            maxarray = maxarray + 1;
                            clubUACM = clubUACM + 1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("End of Array " + ex);
            }

            System.Diagnostics.Debug.WriteLine("Max Array " + maxarray + " club ua array " + clubUACM + " Counter " + counter);

            if (clubUACM > 0)
            {
                //  ApplicantName.Text = "Applicant Name: " + unClubMembers[counter].MemberName;

                if (unClubMembers[counter].MemberRole.Contains("D"))
                {
                    myrole = myrole + " Driver ";
                }
                if (unClubMembers[counter].MemberRole.Contains("P"))
                {
                    myrole = myrole + " Parent ";
                }
                if (unClubMembers[counter].MemberRole.Contains("A"))
                {
                    myrole = myrole + " Admin ";
                }
                if (unClubMembers[counter].MemberRole.Contains("R"))
                {
                    myrole = myrole + " Rider ";
                }
                // ApplicantType.Text = "Applicant Role: " + myrole;
            }


            if (counter == maxarray)
            {
                //PreviousButton.IsEnabled = false;
                //NextButton.IsEnabled = false;
            }
            else if (counter < maxarray)
            {
                //PreviousButton.IsEnabled = false;
                //NextButton.IsEnabled = true;
            }
            else
            {
                //PreviousButton.IsEnabled = false;
                //NextButton.IsEnabled = false;
            }
        }
Beispiel #21
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;
            }
        }
Beispiel #22
0
        async void cdLogin(object sender, System.EventArgs e)
        {
            String        myusername = eusername.Text;
            String        mypassword = epassword.Text;
            cdCallAPI     mycallAPI  = new cdCallAPI();
            loginResponse lresp      = new loginResponse();

            //Authenticating user
            System.Diagnostics.Debug.WriteLine(" Authenticating user");
            System.Diagnostics.Debug.WriteLine(" Long string " + Math.Abs(DateTime.Now.ToBinary()).ToString());
            System.Diagnostics.Debug.WriteLine(" Hash Code " + Math.Abs(DateTime.Now.GetHashCode()));

            var jsreponse = await mycallAPI.cdLoginAccount(myusername, mypassword);

            lresp       = JsonConvert.DeserializeObject <loginResponse>((string)jsreponse);
            App.mylresp = lresp;

            if (lresp.status == "success")
            {
                try
                {
                    System.Diagnostics.Debug.WriteLine(" Authentication Successful ");
                    loginMessage.Text = "Login is Successful";
                    //Getting Account information
                    //Set Query Object
                    Account     myaccount = new Account();
                    cdQueryAttr qryAcct   = new cdQueryAttr();
                    qryAcct.ColIndex  = "IndexName";
                    qryAcct.IndexName = "UserNameindex";
                    qryAcct.ColName   = "UserName";
                    qryAcct.ColValue  = myusername;

                    getAccounts myAccountsArray = new getAccounts();

                    jsreponse = await mycallAPI.cdcallAccountsGET(qryAcct);

                    myAccountsArray = JsonConvert.DeserializeObject <getAccounts>((string)jsreponse);

                    System.Diagnostics.Debug.WriteLine(" Before Account array " + jsreponse);

                    myaccount = myAccountsArray.Account[0];

                    System.Diagnostics.Debug.WriteLine(" After Account array ");

                    System.Diagnostics.Debug.WriteLine("Role for " + myaccount.FirstName + " " + myaccount.LastName + " is " + myaccount.Role);

                    var tpage = new cdAdminDrive(myaccount);
                    await Navigation.PushModalAsync(tpage);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(" Invalid login " + ex);
                    await DisplayAlert("Unable to Login", "Unable to Login", "OK");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(" Authentication Failed ");
                await DisplayAlert("Invalid Username or Password", "Invalid Username or Password", "OK");
            }
        }
Beispiel #23
0
        private async void trackToCurrentLoc(String trackKey)
        {
            Double cPosLat  = 0.00;
            Double cPosLong = 0.00;

            var mypos = new Position(cPosLat, cPosLong);

            var pin = new Pin
            {
                Type     = PinType.Generic,
                Position = mypos,
                Label    = "My Location",
                Address  = ""
            };

            System.Diagnostics.Debug.WriteLine(" Getting Driver Locations ");
            cdQueryAttr qryAcct = new cdQueryAttr();

            qryAcct.ColIndex  = "IndexName";
            qryAcct.IndexName = "cddatetimeindex";
            qryAcct.ColName   = "cddatetime";
            qryAcct.ColValue  = trackKey;

            getTrips  tripArray = new getTrips();
            cdCallAPI mycallAPI = new cdCallAPI();

            while (exitloop == 0)
            {
                try
                {
                    var jsreponse = await mycallAPI.cdcallTrackLocGET(qryAcct);

                    tripArray = JsonConvert.DeserializeObject <getTrips>((string)jsreponse);

                    System.Diagnostics.Debug.WriteLine(" Getting Driver Locations " + jsreponse);

                    cPosLat  = Convert.ToDouble(tripArray.Trips[0].cdLatitude);
                    cPosLong = Convert.ToDouble(tripArray.Trips[0].cdLongitude);

                    var map = new Map(
                        MapSpan.FromCenterAndRadius(
                            new Position(cPosLat, cPosLong), Distance.FromMiles(0.3)))
                    {
                        IsShowingUser   = true,
                        HeightRequest   = 675,
                        WidthRequest    = 960,
                        VerticalOptions = LayoutOptions.FillAndExpand
                    };

                    foreach (var tripLoc in tripArray.Trips)
                    {
                        cPosLat  = Convert.ToDouble(tripLoc.cdLatitude);
                        cPosLong = Convert.ToDouble(tripLoc.cdLongitude);
                        mypos    = new Position(cPosLat, cPosLong);
                    }

                    pin.Position = mypos;

                    map.Pins.Add(pin);
                    mapStack.Children.Add(map);

                    map.MoveToRegion(MapSpan.FromCenterAndRadius(mypos, Distance.FromMiles(1)));
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(" In exception " + ex);
                    await DisplayAlert("Failed to get data. Please try later.", "Failed to get data. Please try later.", "OK");
                }
                await Task.Delay(5000);
            }
        }