public async Task<IHttpActionResult> Post(SecureTicketSeatApiModel[] model)
        {
            if (model == null || model.Length == 0)
            {
                return Ok();
            }

            //Create Order
            DexCMS.Tickets.Orders.Models.Order order = new DexCMS.Tickets.Orders.Models.Order
            {
                EnteredOn = cstTime,
                OrderStatus = OrderStatus.Pending,
                OrderTicketReferences = new List<OrderTicketReference>(),
                UserName = User.Identity.Name
            };

            foreach (var item in model)
            {
                OrderTicketReference ticketRef = new OrderTicketReference
                {
                    TicketSeatID = item.TicketSeatID,
                    PendingPurchaseConfirmation = item.ConfirmationNumber,
                    EventAgeGroupID = item.AgeID,
                    TicketDiscountID = item.TicketDiscountID,
                    SecurityConfirmationNumber = item.DiscountConfirmationNumber,
                    TotalPrice = item.TotalPrice
                };

                if (item.Options != null && item.Options.Count > 0)
                {
                    ticketRef.TicketOptionChoices = new List<int>();
                    foreach (KeyValuePair<int, int> optionChoice in item.Options)
                    {
                        ticketRef.TicketOptionChoices.Add(optionChoice.Value);
                    }
                }

                order.OrderTicketReferences.Add(ticketRef);
            }

            //save
            await repository.AddAsync(order);

            if (order.OrderTotal > 0)
            {
                //Create order with paypal
                var payment = CreatePayment(order);

                var createdPayment = payment.Create(PaypalConfiguration.GetAPIContext());
                var links = createdPayment.links.GetEnumerator();
                var approvalUrl = "";
                while (links.MoveNext())
                {
                    var link = links.Current;
                    if (link.rel.ToLower().Trim().Equals("approval_url"))
                    {
                        approvalUrl = link.href;
                    }
                }

                return Ok(new
                {
                    OrderID = order.OrderID,
                    ApprovalUrl = approvalUrl
                });
            }
            else
            {
                order.Payments = new List<DexCMS.Tickets.Orders.Models.Payment>();

                order.Payments.Add(new DexCMS.Tickets.Orders.Models.Payment
                {
                    GrossPaid = 0,
                    NetPaid = 0,
                    OrderID = order.OrderID,
                    PaidOn = DateTime.Now,
                    PaymentDetails = "{\"type\":\"Automatic\"}",
                    PaymentFee = 0,
                    PaymentType = PaymentType.NoCharge
                });

                order.OrderStatus = OrderStatus.Complete;

                await repository.UpdateAsync(order, order.OrderID);

                return Ok(new { OrderID = order.OrderID });
            }
        }
        public async Task<IHttpActionResult> Post(CashierOrderApiModel model)
        {
            if (model == null || model.Tickets.Length == 0)
            {
                return Ok();
            }

            //Create Order
            DexCMS.Tickets.Orders.Models.Order order = new DexCMS.Tickets.Orders.Models.Order
            {
                EnteredOn = cstTime,
                OrderStatus = OrderStatus.Pending,
                OrderTicketReferences = new List<OrderTicketReference>(),
                UserName = User.Identity.Name
            };

            foreach (var item in model.Tickets)
            {
                OrderTicketReference ticketRef = new OrderTicketReference
                {
                    TicketSeatID = item.TicketSeatID,
                    PendingPurchaseConfirmation = item.ConfirmationNumber,
                    EventAgeGroupID = item.AgeID,
                    TicketDiscountID = item.TicketDiscountID,
                    SecurityConfirmationNumber = item.DiscountConfirmationNumber,
                    TotalPrice = item.TotalPrice
                };

                if (item.Options != null && item.Options.Count > 0)
                {
                    ticketRef.TicketOptionChoices = new List<int>();
                    foreach (KeyValuePair<int, int> optionChoice in item.Options)
                    {
                        ticketRef.TicketOptionChoices.Add(optionChoice.Value);
                    }
                }

                order.OrderTicketReferences.Add(ticketRef);
            }

            //save
            await repository.AddAsync(order);


            //! CHANGING HERE
            switch (model.CashierOrderType)
            {
                case CashierOrderType.CashOrCheck:
                    return Ok(new { OrderID = order.OrderID });

                case CashierOrderType.Paypal:
                     Invoice invoice = CreateInvoice(model.InvoiceEmail, order);
                    invoice.id = order.OrderID.ToString();

                    try
                    {
                        var apiContext = PaypalConfiguration.GetAPIContext();
                        var createdInvoice = invoice.Create(apiContext);
                        createdInvoice.Send(apiContext, true);

                        var invoiceDetails = new
                        {
                            id = createdInvoice.id,
                            email = model.InvoiceEmail
                        };

                        order.Payments = new List<Orders.Models.Payment>
                        {
                            new Orders.Models.Payment
                            {
                                OrderID = order.OrderID,
                                PaymentDetails = JsonConvert.SerializeObject(invoiceDetails),
                                PaymentType = PaymentType.PendingInvoice
                            }
                        };
                        order.OrderStatus = OrderStatus.Pending;

                        await repository.UpdateAsync(order, order.OrderID);
                        return Ok(new { OrderID = order.OrderID });
                    }
                    catch (Exception ex)
                    {
                        await Logger.WriteLog(LogType.Error, ex.ToString());
                        throw ex;
                    }
  
                default:
                    return Ok();
            }          
        }