Esempio n. 1
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;
            }
        }