Example #1
0
        private List<CartSummaryLineItem> GenerateLineItems(SessionCart currentCart)
        {
            List<CartSummaryLineItem> lineItems = new List<CartSummaryLineItem>();
            IRegistrationService regService = new RegistrationService(this._repository, false);

            foreach (var item in currentCart.ActionItems.Where(x => x.Value.ItemReadyForCheckout))
            {

                var lineItem = new CartSummaryLineItem();

                EventService evtService = new EventService(_repository, false);
                Registration reg;
                EventFee fee;
                Event evt;
                EventDate evtDate;
                EventWave evtWave;

                switch (item.Value.ActionType)
                {
                    case CartActionType.NewRegistration:

                        reg = (Registration)item.Value.ActionObject;
                        evtWave = evtService.GetEventWaveById(reg.EventWaveId);
                        evtDate = evtWave.EventDate;
                        evt = evtDate.Event;
                        fee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.Registration);

                        lineItems.Add(GenerateLineItem(evt.EventId,
                                        item.Key,
                                        PurchaseType.Registration,
                                        ProcessType.Individual,
                                        "Registration",
                                        string.Format("{0}, {1} : {2} {3}", evt.GeneralLocality, evt.Region.Code, evtDate.DateOfEvent.ToString("dddd  MMMM dd, yyyy"), evtWave.StartTime.ToString("h:mm tt")),
                                        fee.PurchaseItemId,
                                        reg.RegistrationType == RegistrationType.CancerRegistration ? 0 : fee.Cost,
                                        fee.Discountable,
                                        fee.Taxable,
                                        evt.StateTax,
                                        evt.LocalTax,
                                        true));

                        break;
                    case CartActionType.EventChange:

                        var changeAction = (ChangeEventAction)item.Value.ActionObject;
                        evtWave = evtService.GetEventWaveById(changeAction.UpdatedEventWaveId);
                        evtDate = evtWave.EventDate;
                        evt = evtDate.Event;
                        fee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.ChangeEvent);

                        lineItems.Add(GenerateLineItem(evt.EventId,
                                        item.Key,
                                        PurchaseType.Fee,
                                        ProcessType.General,
                                        "Event Change",
                                        string.Format("Changing your registration to {0}, {1} : {2} {3}", evt.GeneralLocality, evt.Region.Code, evtDate.DateOfEvent.ToString("dddd  MMMM dd, yyyy"), evtWave.StartTime.ToString("h:mm tt")),
                                        fee.PurchaseItemId,
                                        fee.Cost,
                                        false,
                                        false,
                                        null,
                                        null,
                                        true));

                        var originalCost = regService.GetRegistrationPathValue(changeAction.RegistrationId);
                        var regFee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.Registration);

                        if (regFee.Cost > originalCost)
                        {
                            var additionalcost = regFee.Cost - originalCost;

                            lineItems.Add(GenerateLineItem(evt.EventId,
                                            null,
                                            PurchaseType.FeeDifference,
                                            ProcessType.Individual,
                                            "Difference Cost",
                                            string.Format("The event you have selected has a fee difference of {0}.", additionalcost.ToString("c")),
                                            1,
                                            additionalcost,
                                            true,
                                            true,
                                            evt.StateTax,
                                            evt.LocalTax,
                                            true));
                        }

                        break;
                    case CartActionType.TransferRregistration:
                        var transferAction = (TransferAction)item.Value.ActionObject;

                        evtWave = _repository.Registrations.Find(transferAction.RegistrationId).EventWave;
                        evtDate = evtWave.EventDate;
                        evt = evtDate.Event;
                        fee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.Transfer);

                        lineItems.Add(GenerateLineItem(evt.EventId,
                                        item.Key,
                                        PurchaseType.Fee,
                                        ProcessType.General,
                                        "Transfer to friend",
                                        string.Format("Transfering your registration for {0}, {1} : {2} {3} to {4} using {5}.", evt.GeneralLocality, evt.Region.Code, evtDate.DateOfEvent.ToString("dddd  MMMM dd, yyyy"), evtWave.StartTime.ToString("h:mm tt"), string.Format("{0} {1}", transferAction.FirstName, transferAction.LastName), transferAction.Email),
                                        fee.PurchaseItemId,
                                        fee.Cost,
                                        false,
                                        false,
                                        null,
                                        null,
                                        true));

                        break;
                    case CartActionType.CancelRegistration:
                        var cancelAction = (CancellationAction)item.Value.ActionObject;

                        evtWave = _repository.Registrations.Find(cancelAction.RegistrationId).EventWave;
                        evtDate = evtWave.EventDate;
                        evt = evtDate.Event;
                        fee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.Cancellation);

                        lineItems.Add(GenerateLineItem(evt.EventId,
                                        item.Key,
                                        PurchaseType.Fee,
                                        ProcessType.General,
                                        "Cancellation",
                                        string.Format("Cancelling your registration for {0}, {1} : {2} {3}.  You will be issued a cancellation code of the original value that can be used towards another event.", evt.GeneralLocality, evt.Region.Code, evtDate.DateOfEvent.ToString("dddd  MMMM dd, yyyy"), evtWave.StartTime.ToString("h:mm tt")),
                                        fee.PurchaseItemId,
                                        fee.Cost,
                                        false,
                                        false,
                                        null,
                                        null,
                                        true));

                        break;

                    case CartActionType.ShippingFee:

                        var shippingCost = (ShippingFeeAction)item.Value.ActionObject;
                        evtWave = evtService.GetEventWaveById(shippingCost.EventWaveId);
                        evtDate = evtWave.EventDate;
                        evt = evtDate.Event;
                        fee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.Shipping);
                        lineItems.Add(GenerateLineItem(evt.EventId,
                                        item.Key,
                                        PurchaseType.Fee,
                                        ProcessType.General,
                                        "Shipping Fee",
                                        "Shipping Fee for registration packet",
                                        fee.PurchaseItemId,
                                        fee.Cost,
                                        false,
                                        false,
                                        null,
                                        null,
                                        false));
                        break;

                    case CartActionType.ProcessingFee:

                        var processingCost = (ProcessingFeeAction)item.Value.ActionObject;
                        evtWave = evtService.GetEventWaveById(processingCost.EventWaveId);
                        evtDate = evtWave.EventDate;
                        evt = evtDate.Event;
                        fee = evtService.GetCurrentFeeForEvent(evt.EventId, EventFeeType.ProcessingFee);
                        lineItems.Add(GenerateLineItem(evt.EventId,
                                        item.Key,
                                        PurchaseType.Fee,
                                        ProcessType.General,
                                        PROCESSING_FEE,
                                        "",
                                        fee.PurchaseItemId,
                                        fee.Cost,
                                        false,
                                        false,
                                        null,
                                        null,
                                        false));
                        break;
                }

            }

            return lineItems;
        }
Example #2
0
        private CartSummaryLineItem GenerateLineItem(int eventId, Guid? itemId, PurchaseType purchaseType, ProcessType processType, string name, string description, int? purchaseItemId, decimal cost, bool discountable, bool taxable, decimal? stateTax, decimal? localTax, bool removable)
        {
            var lineItem = new CartSummaryLineItem
            {
                EventId = eventId,
                SessionKey = itemId,
                PurchaseType = purchaseType,
                ProcessType = processType,
                ItemName = name,
                ItemDescription = description,
                PurchaseItemId = purchaseItemId.Value,
                ItemCost = cost,
                Discountable = discountable,
                Taxable = taxable,
                Removable = removable
            };

            if (lineItem.Taxable)
            {
                lineItem.StateTaxPercentage = stateTax;
                lineItem.LocalTaxPercentage = localTax;
            }

            return lineItem;
        }