public void GroupEventFeeGroupDiscount()
        {
            Event groupEventFeeGroupDiscount = new Event("RI-GroupEventFeeGroupDiscount");
            GroupDiscount groupDiscount = new GroupDiscount();
            groupDiscount.GroupSize = 2;
            groupDiscount.GroupSizeOption = GroupDiscount_GroupSizeOption.SizeOrMore;
            groupDiscount.DiscountAmount = 1;
            groupDiscount.GroupDiscountType = GroupDiscount_DiscountType.USDollar;
            groupDiscount.AddtionalRegOption = GroupDiscount_AdditionalRegOption.AnyAdditional;
            groupEventFeeGroupDiscount.StartPage.GroupDiscount = groupDiscount;
            RegType regType = new RegType("First");
            regType.Price = 50;
            groupEventFeeGroupDiscount.StartPage.RegTypes.Add(regType);
            PaymentMethod paymentMethod = new PaymentMethod(FormData.PaymentMethod.Check);
            groupEventFeeGroupDiscount.CheckoutPage.PaymentMethods.Add(paymentMethod);

            KeywordProvider.SignIn.SignInAndRecreateEventAndGetEventId(EventFolders.Folders.RegistrationInventory, groupEventFeeGroupDiscount);

            Registrant reg1 = new Registrant(groupEventFeeGroupDiscount);
            reg1.EventFee_Response = new EventFeeResponse(groupEventFeeGroupDiscount.StartPage.RegTypes[0]);
            reg1.Payment_Method = paymentMethod;
            Registrant reg2 = new Registrant(groupEventFeeGroupDiscount);
            reg1.EventFee_Response = new EventFeeResponse(groupEventFeeGroupDiscount.StartPage.RegTypes[0]);
            Group group = new Group();
            group.Primary = reg1;
            group.Secondaries.Add(reg2);

            KeywordProvider.RegistrationCreation.GroupRegistration(group);
        }
        public double CalculateTotalFee(Registrant reg)
        {
            Group group = new Group();
            group.Primary = reg;

            return this.CalculateTotalFee(group);
        }
        private double CalculateAgendaGroupDiscount(double agendaFee, Group group, AgendaResponseCount count)
        {
            double total = 0;

            if (group.Primary.Event.StartPage.GroupDiscount.GroupSizeOption == GroupDiscount_GroupSizeOption.SizeOrMore)
            {
                if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                {
                    total += agendaFee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * count.count;
                }
                else
                {
                    total += group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * count.count;
                }
            }
            else if (group.Primary.Event.StartPage.GroupDiscount.AddtionalRegOption == GroupDiscount_AdditionalRegOption.All)
            {
                for (int i = 1; i <= count.count; i++)
                {
                    if (i % group.Primary.Event.StartPage.GroupDiscount.GroupSize == 0)
                    {
                        if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                        {
                            total += agendaFee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * group.Primary.Event.StartPage.GroupDiscount.GroupSize;
                        }
                        else
                        {
                            total += group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * group.Primary.Event.StartPage.GroupDiscount.GroupSize;
                        }
                    }
                }
            }
            else if (group.Primary.Event.StartPage.GroupDiscount.AddtionalRegOption == GroupDiscount_AdditionalRegOption.AnyAdditional)
            {
                if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                {
                    total += agendaFee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * (count.count - group.Primary.Event.StartPage.GroupDiscount.GroupSize);
                }
                else
                {
                    total += group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * (count.count - group.Primary.Event.StartPage.GroupDiscount.GroupSize);
                }
            }
            else if (group.Primary.Event.StartPage.GroupDiscount.AddtionalRegOption == GroupDiscount_AdditionalRegOption.Additional)
            {
                for (int i = 1; i <= count.count; i++)
                {
                    if ((i > group.Primary.Event.StartPage.GroupDiscount.GroupSize) && (i <= group.Primary.Event.StartPage.GroupDiscount.NumberOfAdditionalReg.Value + count.count))
                    {
                        if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                        {
                            total += agendaFee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0;
                        }
                        else
                        {
                            total += group.Primary.Event.StartPage.GroupDiscount.DiscountAmount;
                        }
                    }
                }
            }

            return total;
        }
        private double CalculateTaxRates(Group group)
        {
            double total = this.CalculateDiscountCode(group);

            List<Registrant> regs = new List<Registrant>();
            regs.Add(group.Primary);

            foreach (Registrant reg in group.Secondaries)
            {
                regs.Add(reg);
            }

            foreach (Registrant reg in regs)
            {
                if ((reg.EventFee_Response != null) && (reg.EventFee_Response.RegType.ApplyTaxOne.HasValue)
                    && (reg.EventFee_Response.RegType.ApplyTaxOne.Value))
                {
                    if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                    {
                        if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                        {
                            total += reg.EventFee_Response.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                        }
                        if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                            && (reg.Country.Value == FormData.Countries.Austria))
                        {
                            total += reg.EventFee_Response.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                        }
                    }
                    else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                    {
                        total += reg.EventFee_Response.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                    }
                }

                if ((reg.EventFee_Response != null) && (reg.EventFee_Response.RegType.ApplyTaxTwo.HasValue)
                    && (reg.EventFee_Response.RegType.ApplyTaxTwo.Value))
                {
                    if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                    {
                        if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                        {
                            total += reg.EventFee_Response.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                        }
                        if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                            && (reg.Country.Value == FormData.Countries.Austria))
                        {
                            total += reg.EventFee_Response.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                        }
                    }
                    else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                    {
                        total += reg.EventFee_Response.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                    }
                }

                foreach (CustomFieldResponse responses in reg.CustomField_Responses)
                {
                    if (responses is AgendaResponse)
                    {
                        AgendaResponse response = responses as AgendaResponse;

                        double taxAmount = 0;

                        switch (response.AgendaItem.Type)
                        {
                            case FormData.CustomFieldType.AlwaysSelected:
                                {
                                    AgendaResponse_AlwaysSelected resp = response as AgendaResponse_AlwaysSelected;
                                    AgendaItem_AlwaysSelected agenda = resp.AgendaItem as AgendaItem_AlwaysSelected;
                                    if ((agenda.ApplyTaxOne.HasValue) && (agenda.ApplyTaxOne.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    if ((agenda.ApplyTaxTwo.HasValue) && (agenda.ApplyTaxTwo.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.CheckBox:
                                {
                                    AgendaResponse_Checkbox resp = response as AgendaResponse_Checkbox;
                                    AgendaItem_CheckBox agenda = resp.AgendaItem as AgendaItem_CheckBox;
                                    if ((agenda.ApplyTaxOne.HasValue) && (agenda.ApplyTaxOne.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    if ((agenda.ApplyTaxTwo.HasValue) && (agenda.ApplyTaxTwo.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.RadioButton:
                                {
                                    AgendaResponse_MultipleChoice_RadioButton resp = response as AgendaResponse_MultipleChoice_RadioButton;
                                    AgendaItem_MultipleChoice_RadioButton agenda = resp.AgendaItem as AgendaItem_MultipleChoice_RadioButton;
                                    if ((agenda.ApplyTaxOne.HasValue) && (agenda.ApplyTaxOne.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    if ((agenda.ApplyTaxTwo.HasValue) && (agenda.ApplyTaxTwo.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.Dropdown:
                                {
                                    AgendaResponse_MultipleChoice_DropDown resp = response as AgendaResponse_MultipleChoice_DropDown;
                                    AgendaItem_MultipleChoice_DropDown agenda = resp.AgendaItem as AgendaItem_MultipleChoice_DropDown;
                                    if ((agenda.ApplyTaxOne.HasValue) && (agenda.ApplyTaxOne.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    if ((agenda.ApplyTaxTwo.HasValue) && (agenda.ApplyTaxTwo.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.FileUpload:
                                {
                                    AgendaResponse_FileUpload resp = response as AgendaResponse_FileUpload;
                                    AgendaItem_FileUpload agenda = resp.AgendaItem as AgendaItem_FileUpload;
                                    if ((agenda.ApplyTaxOne.HasValue) && (agenda.ApplyTaxOne.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    if ((agenda.ApplyTaxTwo.HasValue) && (agenda.ApplyTaxTwo.Value))
                                    {
                                        if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                        {
                                            if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                            if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                                && (reg.Country.Value == FormData.Countries.Austria))
                                            {
                                                taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                            }
                                        }
                                        else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                        {
                                            taxAmount += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                }
                                break;
                            default:
                                break;
                        }

                        total += taxAmount;
                    }
                }

                foreach (MerchandiseResponse response in reg.Merchandise_Responses)
                {
                    switch (response.Merchandise_Item.Type)
                    {
                        case FormData.MerchandiseType.Fixed:
                            {
                                MerchResponse_FixedPrice resp = response as MerchResponse_FixedPrice;
                                if ((resp.Merchandise_Item.ApplyTaxOne.HasValue)
                                    && (resp.Merchandise_Item.ApplyTaxOne.Value))
                                {
                                    if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                    {
                                        if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                        if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                            && (reg.Country.Value == FormData.Countries.Austria))
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                    {
                                        total += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                    }
                                }
                                if ((resp.Merchandise_Item.ApplyTaxTwo.HasValue)
                                    && (resp.Merchandise_Item.ApplyTaxTwo.Value))
                                {
                                    if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                    {
                                        if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                        if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                            && (reg.Country.Value == FormData.Countries.Austria))
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                    else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                    {
                                        total += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                    }
                                }
                            }
                            break;
                        case FormData.MerchandiseType.Variable:
                            {
                                MerchResponse_VariableAmount resp = response as MerchResponse_VariableAmount;
                                if ((resp.Merchandise_Item.ApplyTaxOne.HasValue)
                                    && (resp.Merchandise_Item.ApplyTaxOne.Value))
                                {
                                    if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                    {
                                        if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                        if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                            && (reg.Country.Value == FormData.Countries.Austria))
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                        }
                                    }
                                    else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                    {
                                        total += resp.Fee * group.Primary.Event.TaxRateOne.Rate / 100.00;
                                    }
                                }
                                if ((resp.Merchandise_Item.ApplyTaxTwo.HasValue)
                                    && (resp.Merchandise_Item.ApplyTaxTwo.Value))
                                {
                                    if ((group.Primary.Event.TaxRateOne.Country.HasValue) && (reg.Country.HasValue))
                                    {
                                        if (group.Primary.Event.TaxRateOne.Country.Value == reg.Country.Value)
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                        if ((group.Primary.Event.TaxRateOne.Country.Value == DataCollection.FormData.Countries.EU)
                                            && (reg.Country.Value == FormData.Countries.Austria))
                                        {
                                            total += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                        }
                                    }
                                    else if (!group.Primary.Event.TaxRateOne.Country.HasValue)
                                    {
                                        total += resp.Fee * group.Primary.Event.TaxRateTwo.Rate / 100.00;
                                    }
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            return total;
        }
        private double CalculateGroupDiscount(Group group)
        {
            double total = 0;

            total += this.CalculateSingleReg(group.Primary);

            foreach (Registrant reg in group.Secondaries)
            {
                total += this.CalculateSingleReg(reg);
            }

            List<Registrant> regs = new List<Registrant>();

            regs.Add(group.Primary);

            foreach (Registrant reg in group.Secondaries)
            {
                regs.Add(reg);
            }

            List<EventFeeResponse> regEventFeeResponses = new List<EventFeeResponse>();
            List<AgendaResponse> regAgendaResponses = new List<AgendaResponse>();

            foreach (Registrant reg in regs)
            {
                if (reg.EventFee_Response != null)
                {
                    regEventFeeResponses.Add(reg.EventFee_Response);
                }

                foreach (CustomFieldResponse resp in reg.CustomField_Responses)
                {
                    if (resp is AgendaResponse)
                    {
                        AgendaResponse response = resp as AgendaResponse;

                        switch (response.AgendaItem.Type)
                        {
                            case FormData.CustomFieldType.AlwaysSelected:
                            case FormData.CustomFieldType.CheckBox:
                            case FormData.CustomFieldType.RadioButton:
                            case FormData.CustomFieldType.Dropdown:
                            case FormData.CustomFieldType.Contribution:
                            case FormData.CustomFieldType.FileUpload:
                                regAgendaResponses.Add(response);
                                break;
                            default:
                                break;
                        }
                    }
                }
            }

            List<EventFeeResponseCount> eventFeeResponseCount = new List<EventFeeResponseCount>();
            List<AgendaResponseCount> agendaResponseCount = new List<AgendaResponseCount>();

            foreach (EventFeeResponse resp in regEventFeeResponses)
            {
                if (eventFeeResponseCount.Exists(e => e.EventFee_Response.RegType == resp.RegType))
                {
                    eventFeeResponseCount.Find(e => e.EventFee_Response.RegType == resp.RegType).count += 1;
                }
                else if ((group.Primary.Event.StartPage.GroupDiscount != null)
                    && group.Primary.Event.StartPage.GroupDiscount.ApplyToRegTypes.Count != 0)
                {
                    if (group.Primary.Event.StartPage.GroupDiscount.ApplyToRegTypes.Exists(r => r == resp.RegType))
                    {
                        EventFeeResponseCount responseCount = new EventFeeResponseCount();
                        responseCount.EventFee_Response = resp;
                        responseCount.count = 1;
                        eventFeeResponseCount.Add(responseCount);
                    }
                }
                else
                {
                    EventFeeResponseCount responseCount = new EventFeeResponseCount();
                    responseCount.EventFee_Response = resp;
                    responseCount.count = 1;
                    eventFeeResponseCount.Add(responseCount);
                }
            }

            foreach (AgendaResponse resp in regAgendaResponses)
            {
                if (agendaResponseCount.Exists(a => a.Agenda_Response.AgendaItem == resp.AgendaItem))
                {
                    agendaResponseCount.Find(a => a.Agenda_Response.AgendaItem == resp.AgendaItem).count += 1;
                }
                else if ((group.Primary.Event.StartPage.GroupDiscount != null)
                    && group.Primary.Event.StartPage.GroupDiscount.ApplyToAgendaItems.Count != 0)
                {
                    if (group.Primary.Event.StartPage.GroupDiscount.ApplyToAgendaItems.Exists(a => a == resp.AgendaItem))
                    {
                        AgendaResponseCount responseCount = new AgendaResponseCount();
                        responseCount.Agenda_Response = resp;
                        responseCount.count = 1;
                        agendaResponseCount.Add(responseCount);
                    }
                }
                else
                {
                    AgendaResponseCount responseCount = new AgendaResponseCount();
                    responseCount.Agenda_Response = resp;
                    responseCount.count = 1;
                    agendaResponseCount.Add(responseCount);
                }
            }

            foreach (EventFeeResponseCount count in eventFeeResponseCount)
            {
                if ((group.Primary.Event.StartPage.GroupDiscount != null) &&
                    (count.count >= group.Primary.Event.StartPage.GroupDiscount.GroupSize) &&
                    (group.Primary.Event.StartPage.GroupDiscount.ShowAndApply))
                {
                    if (group.Primary.Event.StartPage.GroupDiscount.GroupSizeOption == GroupDiscount_GroupSizeOption.SizeOrMore)
                    {
                        if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                        {
                            total -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * count.count;
                            count.EventFee_Response.Fee -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * count.count;
                        }
                        else
                        {
                            total -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * count.count;
                            count.EventFee_Response.Fee -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * count.count;
                        }
                    }
                    else if (group.Primary.Event.StartPage.GroupDiscount.AddtionalRegOption == GroupDiscount_AdditionalRegOption.All)
                    {
                        for (int i = 1; i <= count.count; i++)
                        {
                            if (i % group.Primary.Event.StartPage.GroupDiscount.GroupSize == 0)
                            {
                                if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                                {
                                    total -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * group.Primary.Event.StartPage.GroupDiscount.GroupSize;
                                    count.EventFee_Response.Fee -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * group.Primary.Event.StartPage.GroupDiscount.GroupSize;
                                }
                                else
                                {
                                    total -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * group.Primary.Event.StartPage.GroupDiscount.GroupSize;
                                    count.EventFee_Response.Fee -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * group.Primary.Event.StartPage.GroupDiscount.GroupSize;
                                }
                            }
                        }
                    }
                    else if (group.Primary.Event.StartPage.GroupDiscount.AddtionalRegOption == GroupDiscount_AdditionalRegOption.AnyAdditional)
                    {
                        if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                        {
                            total -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * (count.count - group.Primary.Event.StartPage.GroupDiscount.GroupSize);
                            count.EventFee_Response.Fee -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0 * (count.count - group.Primary.Event.StartPage.GroupDiscount.GroupSize);
                        }
                        else
                        {
                            total -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * (count.count - group.Primary.Event.StartPage.GroupDiscount.GroupSize);
                            count.EventFee_Response.Fee -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount * (count.count - group.Primary.Event.StartPage.GroupDiscount.GroupSize);
                        }
                    }
                    else if (group.Primary.Event.StartPage.GroupDiscount.AddtionalRegOption == GroupDiscount_AdditionalRegOption.Additional)
                    {
                        for (int i = 1; i <= count.count; i++)
                        {
                            if ((i > group.Primary.Event.StartPage.GroupDiscount.GroupSize) && (i <= group.Primary.Event.StartPage.GroupDiscount.NumberOfAdditionalReg.Value))
                            {
                                if (group.Primary.Event.StartPage.GroupDiscount.GroupDiscountType == GroupDiscount_DiscountType.Percent)
                                {
                                    total -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0;
                                    count.EventFee_Response.Fee -= count.EventFee_Response.Fee * group.Primary.Event.StartPage.GroupDiscount.DiscountAmount / 100.0;
                                }
                                else
                                {
                                    total -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount;
                                    count.EventFee_Response.Fee -= group.Primary.Event.StartPage.GroupDiscount.DiscountAmount;
                                }
                            }
                        }
                    }
                }
            }

            foreach (AgendaResponseCount count in agendaResponseCount)
            {
                if ((group.Primary.Event.StartPage.GroupDiscount != null)
                    && (count.count >= group.Primary.Event.StartPage.GroupDiscount.GroupSize)
                    && (group.Primary.Event.StartPage.GroupDiscount.ShowAndApply))
                {
                    switch(count.Agenda_Response.AgendaItem.Type)
                    {
                        case FormData.CustomFieldType.AlwaysSelected:
                            AgendaResponse_AlwaysSelected respAlways = count.Agenda_Response as AgendaResponse_AlwaysSelected;
                            respAlways.Fee = total -= this.CalculateAgendaGroupDiscount(respAlways.Fee, group, count);
                            break;
                        case FormData.CustomFieldType.CheckBox:
                            AgendaResponse_Checkbox respCheck = count.Agenda_Response as AgendaResponse_Checkbox;
                            respCheck.Fee = total -= this.CalculateAgendaGroupDiscount(respCheck.Fee, group, count);
                            break;
                        case FormData.CustomFieldType.RadioButton:
                            AgendaResponse_MultipleChoice_RadioButton respRadio = count.Agenda_Response as AgendaResponse_MultipleChoice_RadioButton;
                            respRadio.Fee = total -= this.CalculateAgendaGroupDiscount(respRadio.Fee, group, count);
                            break;
                        case FormData.CustomFieldType.Dropdown:
                            AgendaResponse_MultipleChoice_DropDown respDrop = count.Agenda_Response as AgendaResponse_MultipleChoice_DropDown;
                            respDrop.Fee = total -= this.CalculateAgendaGroupDiscount(respDrop.Fee, group, count);
                            break;
                        case FormData.CustomFieldType.Contribution:
                            AgendaResponse_Contribution respContri = count.Agenda_Response as AgendaResponse_Contribution;
                            respContri.ContributionAmount = total -= this.CalculateAgendaGroupDiscount(respContri.ContributionAmount, group, count);
                            break;
                        case FormData.CustomFieldType.FileUpload:
                            AgendaResponse_FileUpload respFile = count.Agenda_Response as AgendaResponse_FileUpload;
                            respFile.Fee = total -= this.CalculateAgendaGroupDiscount(respFile.Fee, group, count);
                            break;
                        default:
                            break;
                    }
                }
            }

            return total;
        }
        private double CalculateDiscountCode(Group group)
        {
            double total = this.CalculateGroupDiscount(group);

            List<Registrant> regs = new List<Registrant>();
            regs.Add(group.Primary);

            foreach (Registrant reg in group.Secondaries)
            {
                regs.Add(reg);
            }

            foreach (Registrant reg in regs)
            {
                if ((reg.EventFee_Response != null) && (reg.EventFee_Response.Code != null))
                {
                    reg.EventFee_Response.Fee = total -= reg.EventFee_Response.Fee - reg.EventFee_Response.Code.CalculateDiscountedPrice(reg.EventFee_Response.Fee);
                }

                foreach (CustomFieldResponse responses in reg.CustomField_Responses)
                {
                    if (responses is AgendaResponse)
                    {
                        AgendaResponse response = responses as AgendaResponse;

                        switch (response.AgendaItem.Type)
                        {
                            case FormData.CustomFieldType.AlwaysSelected:
                                {
                                    AgendaResponse_AlwaysSelected resp = response as AgendaResponse_AlwaysSelected;
                                    if (resp.Code != null)
                                    {
                                        resp.Fee = total -= resp.Fee - resp.Code.CalculateDiscountedPrice(resp.Fee);
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.CheckBox:
                                {
                                    AgendaResponse_Checkbox resp = response as AgendaResponse_Checkbox;
                                    if (resp.Code != null)
                                    {
                                        resp.Fee = total -= resp.Fee - resp.Code.CalculateDiscountedPrice(resp.Fee);
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.RadioButton:
                                {
                                    AgendaResponse_MultipleChoice_RadioButton resp = response as AgendaResponse_MultipleChoice_RadioButton;
                                    if (resp.Code != null)
                                    {
                                        resp.Fee = total -= resp.Fee - resp.Code.CalculateDiscountedPrice(resp.Fee);
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.Dropdown:
                                {
                                    AgendaResponse_MultipleChoice_DropDown resp = response as AgendaResponse_MultipleChoice_DropDown;
                                    if (resp.Code != null)
                                    {
                                        resp.Fee = total -= resp.Fee - resp.Code.CalculateDiscountedPrice(resp.Fee);
                                    }
                                }
                                break;
                            case FormData.CustomFieldType.FileUpload:
                                {
                                    AgendaResponse_FileUpload resp = response as AgendaResponse_FileUpload;
                                    if (resp.Code != null)
                                    {
                                        resp.Fee = total -= resp.Fee - resp.Code.CalculateDiscountedPrice(resp.Fee);
                                    }
                                }
                                break;
                            default:
                                throw new ArgumentException(string.Format("Agenda item of specified type has no price: {0}", response.AgendaItem.Type));
                        }
                    }
                }

                foreach (MerchandiseResponse response in reg.Merchandise_Responses)
                {
                    switch (response.Merchandise_Item.Type)
                    {
                        case FormData.MerchandiseType.Fixed:
                            {
                                MerchResponse_FixedPrice resp = response as MerchResponse_FixedPrice;
                                if (resp.Discount_Code != null)
                                {
                                    resp.Fee = total -= (resp.Fee - resp.Discount_Code.CalculateDiscountedPrice(resp.Fee)) * resp.Quantity;
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            return total;
        }
 public double CalculateTotalFee(Group group)
 {
     return this.CalculateTaxRates(group);
 }
        public void GroupRegistration(Group group)
        {
            Checkin(group.Primary);
            PersonalInfo(group.Primary);
            Agenda(group.Primary);
            Merchandise(group.Primary);

            for (int i = 0; i <= group.Secondaries.Count - 1; i++)
            {
                PageObject.PageObjectProvider.Register.RegistationSite.AddAnotherPerson_Click();

                PageObject.PageObjectProvider.Register.RegistationSite.Checkin.EmailAddress.Type(group.Secondaries[i].Email);

                if (group.Secondaries[i].EventFee_Response != null)
                {
                    KeywordProvider.RegisterDefault.SelectRegType(group.Secondaries[i]);
                    KeywordProvider.RegisterDefault.TypeEventFeeDiscountCode(group.Secondaries[i]);
                }

                PageObject.PageObjectProvider.Register.RegistationSite.Continue_Click();
                PersonalInfo(group.Secondaries[i]);
                Agenda(group.Secondaries[i]);

                if (group.Secondaries[i].Merchandise_Responses.Count != 0)
                {
                    Merchandise(group.Secondaries[i]);
                }
                else if (group.Primary.Event.MerchandisePage != null)
                {
                    PageObject.PageObjectProvider.Register.RegistationSite.Continue_Click();
                }
            }

            Checkout(group.Primary);
        }
        public void UpdateGroup_AddAPerson_RegType()
        {
            Event evt = new Event("RI-GroupRegistrationRegType");
            RegType regType = new RegType("First");
            evt.StartPage.RegTypes.Add(regType);

            KeywordProvider.SignIn.SignInAndRecreateEventAndGetEventId(EventFolders.Folders.RegistrationInventory, evt);

            Registrant reg1 = new Registrant(evt);
            Registrant reg2 = new Registrant(evt);
            reg1.EventFee_Response = new EventFeeResponse(regType);
            reg2.EventFee_Response = new EventFeeResponse(regType);
            Group group = new Group();
            group.Primary = reg1;
            group.Secondaries.Add(reg2);

            KeywordProvider.RegistrationCreation.GroupRegistration(group);

            PageObject.PageObjectProvider.Register.RegistationSite.Confirmation.ChangeMyRegistration_Click();
            KeywordProvider.RegistrationCreation.Login(reg1);
            PageObject.PageObjectProvider.Register.RegistationSite.AddAnotherPerson_Click();

            Registrant reg3 = new Registrant(evt);
            reg3.EventFee_Response = new EventFeeResponse(regType);

            KeywordProvider.RegistrationCreation.Checkin(reg3);
            KeywordProvider.RegistrationCreation.PersonalInfo(reg3);
            KeywordProvider.RegistrationCreation.Checkout(reg3);
        }
        public void UpdateGroup_AddAPerson_ForceSameRegType()
        {
            Event evt = new Event("RI-GroupRegistrationForceSameRegType");
            RegType regType = new RegType("First");
            evt.StartPage.RegTypes.Add(regType);
            evt.StartPage.ForceSelectSameRegType = true;

            KeywordProvider.SignIn.SignInAndRecreateEventAndGetEventId(EventFolders.Folders.RegistrationInventory, evt);

            Registrant reg1 = new Registrant(evt);
            Registrant reg2 = new Registrant(evt);
            reg1.EventFee_Response = new EventFeeResponse(regType);
            Group group = new Group();
            group.Primary = reg1;
            group.Secondaries.Add(reg2);

            KeywordProvider.RegistrationCreation.GroupRegistration(group);

            PageObject.PageObjectProvider.Register.RegistationSite.Confirmation.ChangeMyRegistration_Click();
            KeywordProvider.RegistrationCreation.Login(reg1);
            PageObject.PageObjectProvider.Register.RegistationSite.AddAnotherPerson_Click();

            Registrant reg3 = new Registrant(evt);

            Assert.False(PageObject.PageObjectProvider.Register.RegistationSite.Checkin.RegTypeRadioButton.IsPresent);
            Assert.False(PageObject.PageObjectProvider.Register.RegistationSite.Checkin.RegTypeDropDown.IsPresent);
            KeywordProvider.RegistrationCreation.CreateRegistration(reg3);
        }
        public void GroupUniqueEmail()
        {
            this.groupUniqueEmailEvent = new Event("RI-GroupRegistration");

            KeywordProvider.SignIn.SignInAndRecreateEventAndGetEventId(
                EventFolders.Folders.RegistrationInventory,
                this.groupUniqueEmailEvent,
                false);

            Registrant reg1 = new Registrant(this.groupUniqueEmailEvent);
            Registrant reg2 = new Registrant(this.groupUniqueEmailEvent);
            this.emailAddress = reg1.Email;
            Group group = new Group();
            group.Primary = reg1;
            group.Secondaries.Add(reg2);

            KeywordProvider.RegistrationCreation.GroupRegistration(group);
        }
        public void GroupInvalidPassword()
        {
            Event evt = new Event("RI-GroupInvalidPassword");

            KeywordProvider.SignIn.SignInAndRecreateEventAndGetEventId(EventFolders.Folders.RegistrationInventory, evt, false, false);

            Registrant reg1 = new Registrant(evt);
            Registrant reg2 = new Registrant(evt);
            Group group = new Group();
            group.Primary = reg1;
            group.Secondaries.Add(reg2);

            KeywordProvider.RegistrationCreation.GroupRegistration(group);

            PageObject.PageObjectProvider.Register.RegistationSite.Confirmation.ChangeMyRegistration_Click();

            PageObject.PageObjectProvider.Register.RegistationSite.Login.Password.Type("abcdefg");
            PageObject.PageObjectProvider.Register.RegistationSite.Continue_Click();

            Assert.True(KeywordProvider.RegisterDefault.HasErrorMessage(Messages.RegisterError.InvalidPassword));
        }
 private void GroupRegistrationAndVerifyTotal(Group group)
 {
     KeywordProvider.RegistrationCreation.GroupRegistration(group);
     Assert.AreEqual(KeywordProvider.RegisterDefault.GetTotal(FormData.RegisterPage.Confirmation),
         KeywordProvider.CalculateFee.CalculateTotalFee(group));
 }
        private Group GenerateGroup(int groupSize)
        {
            this.resp1.RegType = this.regType1;
            this.resp1.Fee = 20;
            this.resp2.RegType = this.regType2;
            this.resp2.Fee = 30;
            this.resp3.AgendaItem = this.agenda1;
            this.resp3.Checked = true;
            this.resp3.Fee = 40;
            this.resp4.AgendaItem = this.agenda2;
            this.resp4.Checked = true;
            this.resp4.Fee = 50;
            this.resp5.Merchandise_Item = this.merch1;
            this.resp5.Quantity = 1;
            this.resp5.Fee = 60;
            this.resp6.Merchandise_Item = this.merch2;
            this.resp6.Amount = 70;
            this.resp6.Fee = 70;

            Registrant reg1 = new Registrant(evt1);
            reg1.Payment_Method = paymentMethod;
            reg1.EventFee_Response = resp1;
            reg1.CustomField_Responses.Add(resp3);
            reg1.CustomField_Responses.Add(resp4);
            reg1.Merchandise_Responses.Add(resp5);
            reg1.Merchandise_Responses.Add(resp6);
            System.Threading.Thread.Sleep(10);

            Registrant reg2 = new Registrant(evt1);
            reg2.Payment_Method = paymentMethod;
            reg2.EventFee_Response = resp2;
            reg2.CustomField_Responses.Add(resp3);
            System.Threading.Thread.Sleep(10);

            Registrant reg3 = new Registrant(evt1);
            reg3.Payment_Method = paymentMethod;
            reg3.EventFee_Response = resp1;
            reg3.CustomField_Responses.Add(resp4);
            System.Threading.Thread.Sleep(10);

            Registrant reg4 = new Registrant(evt1);
            reg4.Payment_Method = paymentMethod;
            reg4.EventFee_Response = resp2;
            reg4.CustomField_Responses.Add(resp3);
            reg4.CustomField_Responses.Add(resp4);

            Group group = new Group();
            group.Primary = reg1;
            group.Secondaries.Add(reg2);

            if (groupSize >= 3)
            {
                group.Secondaries.Add(reg3);
            }

            if (groupSize >= 4)
            {
                group.Secondaries.Add(reg4);
            }

            return group;
        }