Ejemplo n.º 1
0
        public async Task <int> GenerateEventRegistrationInvoice(int eventRegistrationId)
        {
            var apiEventResource = $"rpc/{_accountId}/GenerateInvoiceForEventRegistration";

            var query = new List <string>
            {
                $"eventRegistrationId={eventRegistrationId}",
                "updateIfexists=false"
            };

            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.PostRequest(apiEventResource, token, null, query);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

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

            var result = JsonConvert.DeserializeObject <GenerateEventRegistrationInvoiceResponse>(content);

            return(result.Id);
        }
Ejemplo n.º 2
0
        public async Task <int> MarkInvoiceAsPaid(WildApricotRegistrationType registrationType, int invoiceId, int contactId)
        {
            var newInvoice = new NewInvoice
            {
                Value    = registrationType.BasePrice,
                Invoices = new List <Invoice>
                {
                    new Invoice
                    {
                        Id = invoiceId
                    }
                },
                Contact = new InvoiceContact
                {
                    Id = contactId
                },
                Comment     = "Marked paid by the MITS Web application",
                PaymentType = "InvoicePayment"
            };

            var contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };

            var newInvoiceString = JsonConvert.SerializeObject(newInvoice, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
            });

            var encodedContact = new StringContent(newInvoiceString, Encoding.UTF8, "application/json");

            var apiEventResource = $"accounts/{_accountId}/payments";
            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.PostRequest(apiEventResource, token, encodedContact);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

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

            var result = JsonConvert.DeserializeObject <NewInvoiceResponse>(content);

            return(result.Id);
        }
Ejemplo n.º 3
0
        public async Task <Contact> CreateContact(Registration newRegistration)
        {
            var newContact = new NewContact
            {
                FirstName       = newRegistration.FirstName,
                LastName        = newRegistration.LastName,
                Email           = newRegistration.Email,
                Organization    = newRegistration.Organization,
                Status          = "Active",
                RecreateInvoice = false
            };

            var contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };

            var newContactString = JsonConvert.SerializeObject(newContact, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
            });

            var encodedContact = new StringContent(newContactString, Encoding.UTF8, "application/json");

            var apiEventResource = $"accounts/{_accountId}/contacts";
            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.PostRequest(apiEventResource, token, encodedContact);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

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

            var result = JsonConvert.DeserializeObject <NewContactResponse>(content);

            return(new Contact
            {
                FirstName = result.FirstName,
                LastName = result.LastName,
                Email = result.Email,
                Organization = result.Organization,
                Status = "Active",
                Id = result.Id
            });
        }
Ejemplo n.º 4
0
        public async Task <bool> DeleteEventRegistration(int registrationId)
        {
            var apiEventResource = $"accounts/{_accountId}/eventregistrations/{registrationId}";
            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.PostRequest(apiEventResource, token);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

            return(response.IsSuccessStatusCode);
        }
Ejemplo n.º 5
0
        public async Task <bool> CheckInEventAttendee(int registrationId)
        {
            var newEventRegistrationCheckIn = new EventRegistrationCheckIn
            {
                RegistrationId = registrationId,
                CheckedIn      = true
            };

            var contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };

            var newEventRegistrationCheckInString = JsonConvert.SerializeObject(newEventRegistrationCheckIn, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
            });

            var encodedContact = new StringContent(newEventRegistrationCheckInString, Encoding.UTF8, "application/json");

            var apiEventResource = $"rpc/{_accountId}/CheckInEventAttendee";
            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.PostRequest(apiEventResource, token, encodedContact);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

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

            var result = content.Contains("true");

            return(result);
        }
Ejemplo n.º 6
0
        public async Task <int> AddSponsorRegistration(Sponsor newSponsor, int contactId)
        {
            var newRegistrationData = new NewEventRegistration
            {
                Event = new WaEvent
                {
                    Id = newSponsor.EventId
                },
                Contact = new WaContact
                {
                    Id = contactId
                },
                RegistrationTypeId = newSponsor.RegistrationTypeId,
                IsCheckedIn        = false,
                RegistrationFields = new List <RegistrationField>
                {
                    new RegistrationField
                    {
                        FieldName  = "First name",
                        Value      = newSponsor.FirstName,
                        SystemCode = "FirstName"
                    },
                    new RegistrationField
                    {
                        FieldName  = "Last name",
                        Value      = newSponsor.LastName,
                        SystemCode = "LastName"
                    },
                    new RegistrationField
                    {
                        FieldName  = "Title",
                        Value      = newSponsor,
                        SystemCode = "Title"
                    },
                    new RegistrationField
                    {
                        FieldName  = "e-mail",
                        Value      = newSponsor.Email,
                        SystemCode = "Email"
                    },
                    new RegistrationField
                    {
                        FieldName  = "Registration Terms and Conditions",
                        Value      = true,
                        SystemCode = "custom-10687529"
                    }
                },
                Memo = "Event Registration Created by MITS Web App"
            };

            var contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };

            var newRegistrationString = JsonConvert.SerializeObject(newRegistrationData, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
            });

            var encodedRegistration = new StringContent(newRegistrationString, Encoding.UTF8, "application/json");

            var apiEventResource = $"accounts/{_accountId}/eventregistrations";
            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.PostRequest(apiEventResource, token, encodedRegistration);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

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

            var result = JsonConvert.DeserializeObject <EventRegistrationResponse>(content);

            return(result.Id);
        }