public ActionResult EnrollmentComplete(string token)
        {
            var model        = new EnrollmentCompleteViewModel();
            var args         = Security.Decrypt(token);
            var hasOrder     = args["OrderID"] != null;
            var hasAutoOrder = args["AutoOrderID"] != null;

            model.CustomerID = Convert.ToInt32(args["CustomerID"]);
            if (hasOrder)
            {
                model.OrderID = Convert.ToInt32(args["OrderID"]);
                model.Order   = ExigoDAL.GetCustomerOrders(new GetCustomerOrdersRequest
                {
                    CustomerID          = model.CustomerID,
                    OrderID             = model.OrderID,
                    IncludeOrderDetails = true,
                    IncludePayments     = true
                }).FirstOrDefault();
            }
            if (hasAutoOrder)
            {
                model.AutoOrderID = Convert.ToInt32(args["AutoOrderID"]);
                try
                {
                    model.AutoOrder = ExigoDAL.GetCustomerAutoOrders(Identity.Customer.CustomerID, model.AutoOrderID).FirstOrDefault();
                }
                catch { }
            }

            return(View(model));
        }
        public ActionResult OrderList(int page = 1, int count = 0)
        {
            var model = new GetCustomerOrdersResponse();

            try
            {
                model = ExigoDAL.GetCustomerOrders_SQL(new GetCustomerOrdersRequest
                {
                    CustomerID          = Identity.Customer.CustomerID,
                    Page                = page,
                    RowCount            = RowCount,
                    LanguageID          = CurrentLanguage.LanguageID,
                    IncludeOrderDetails = true,
                    TotalRowCount       = count
                });

                // Check for brand new Orders in our NewOrders cookie
                #region New Order Logic
                // Create a cookie to store our newest Order ID to ensure it shows on the Order History page
                var orderIDCookie = Request.Cookies["NewOrder_{0}".FormatWith(Identity.Customer.CustomerID)];

                if (orderIDCookie != null && orderIDCookie.Value.CanBeParsedAs <int>())
                {
                    int newOrderID = Convert.ToInt32(orderIDCookie.Value);

                    if (model.Orders.Any(c => c.OrderID == newOrderID))
                    {
                        Response.Cookies["NewOrder_{0}".FormatWith(Identity.Customer.CustomerID)].Expires = DateTime.Now.AddDays(-1);
                    }
                    else
                    {
                        var newApiOrder = ExigoDAL.GetCustomerOrders(new GetCustomerOrdersRequest
                        {
                            CustomerID          = Identity.Customer.CustomerID,
                            IncludeOrderDetails = true,
                            LanguageID          = CurrentLanguage.LanguageID,
                            OrderID             = newOrderID,
                            TotalRowCount       = 1
                        }).FirstOrDefault();

                        if (newApiOrder != null)
                        {
                            model.Orders.Add(newApiOrder);
                            RowCount = RowCount + 1;
                        }
                    }
                }
                #endregion

                model.RowCount = RowCount;
                model.Page     = page;

                if (Request.IsAjaxRequest())
                {
                    model.Page = page++;
                    var orderNodes = this.RenderPartialViewToString("Partials/_OrderListRows", model);
                    var pagination = this.RenderPartialViewToString("Partials/_OrderListPagination", model);

                    return(new JsonNetResult(new
                    {
                        success = true,
                        orderNodes,
                        pagination
                    }));
                }
            }
            catch (Exception ex)
            {
                if (Request.IsAjaxRequest())
                {
                    return(new JsonNetResult(new
                    {
                        success = false,
                        message = ex.Message
                    }));
                }
            }

            return(View("OrderList", model));
        }