Ejemplo n.º 1
0
        public static void AuthorizeOrder(dynamic customer, dynamic order)
        {
            dynamic itemTable        = new OrderItems();
            dynamic productionsTable = new Productions();
            dynamic customersTable   = new Customers();

            //loop the items and set auth accordingly
            foreach (var item in itemTable.Find(OrderID:order.ID))
            {
                if (item.SKU == "monthly")
                {
                    //bump the customer's streaming
                    if (customer.StreamUntil < DateTime.Today.AddMonths(-1))
                    {
                        customer.StreamUntil = DateTime.Today.AddMonths(-1);
                    }
                    customer.StreamUntil = customer.StreamUntil.AddMonths(1);
                    customersTable.Update(customer, customer.ID);
                }
                else if (item.SKU == "yearly")
                {
                    if (customer.StreamUntil < DateTime.Today.AddYears(-1))
                    {
                        customer.StreamUntil = DateTime.Today.AddYears(-1);
                    }

                    if (customer.DownloadUntil < DateTime.Today.AddYears(-1))
                    {
                        customer.DownloadUntil = DateTime.Today.AddYears(-1);
                    }

                    customer.StreamUntil   = customer.StreamUntil.AddYears(1);
                    customer.DownloadUntil = customer.DownloadUntil.AddYears(1);
                    customersTable.Update(customer, customer.ID);
                }
                else
                {
                    Authorize(customer, productionsTable.First(Slug: item.SKU));
                }
            }
        }