async void cdSubmit(object sender, System.EventArgs e)
        {
            try
            {
                if (cdSignupRider.IsChecked == true)
                {
                    cdEventSignups insertEventMembers = new cdEventSignups();
                    insertEventMembers.EventID          = pEventID;
                    insertEventMembers.EventName        = pEventName;
                    insertEventMembers.ClubName         = pClubName;
                    insertEventMembers.ClubID           = pClubID;
                    insertEventMembers.PickupLocation   = pEventAddress;
                    insertEventMembers.AllocationStatus = "UNALLOCATED";
                    insertEventMembers.DriverCar        = "NA";
                    insertEventMembers.RiderCount       = "0";
                    insertEventMembers.Attr1            = "None";
                    insertEventMembers.Attr2            = "None";
                    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    = myStudentArray.Account[counter].UserName + pClubName.Substring(0, 3) + pEventName.Substring(0, 3) + (Math.Abs(DateTime.Now.ToBinary()).ToString());
                    insertEventMembers.MemberName       = myStudentArray.Account[counter].FirstName + " " + myStudentArray.Account[counter].LastName;
                    insertEventMembers.MemberAccountID  = myStudentArray.Account[counter].UserName;
                    insertEventMembers.MemberRole       = "R";
                    ieventmem(insertEventMembers);
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Action", "Unable to insert event members. Try later. ", "Ok");

                System.Diagnostics.Debug.WriteLine("Unable to insert event members " + ex);
            }
        }
Beispiel #2
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);
                }
            }
        }