public ActionResult FetchEditAutoOrderOrderModule(int autoorderid)
        {
            var autoorder = Exigo.GetCustomerAutoOrder(Identity.Customer.CustomerID, autoorderid);

            var configuration = Identity.Customer.Market.Configuration.AutoOrders;
            var products      = Exigo.GetItems(new ExigoService.GetItemsRequest
            {
                Configuration          = configuration,
                IncludeChildCategories = true
            }).ToList();

            var orderItems   = autoorder.Details.ToList();
            var itemCodeList = orderItems.Select(c => c.ItemCode).ToList();

            products.Where(p => itemCodeList.Contains(p.ItemCode)).ToList().ForEach(p => products.Remove(p));


            // Populate our model with the products and the Auto Order
            var model = new AutoOrderAddEditCartViewModel();

            model.AutoOrder    = autoorder;
            model.ProductsList = products;


            string html = RenderPartialViewToString("displaytemplates/autoordereditorder", model);

            return(new JsonNetResult(new
            {
                success = true,
                module = html
            }));
        }
        public JsonNetResult SetAutoOrderPaymentMethodPreference(int autoorderid, AutoOrderPaymentType type)
        {
            try
            {
                Exigo.UpdateCustomerAutoOrderPaymentMethod(Identity.Customer.CustomerID, autoorderid, type);

                var model   = Exigo.GetCustomerAutoOrder(Identity.Customer.CustomerID, autoorderid);
                var partial = RenderPartialViewToString("displaytemplates/autoorderrow", model);

                return(new JsonNetResult(new
                {
                    success = true,
                    html = partial,
                    autoorderid = autoorderid
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public ActionResult UpdateAutoOrderShipMethod(int shipMethodID)
        {
            try
            {
                var autoorderid = Convert.ToInt32(Request.Form["autoorderid"]);

                Exigo.UpdateCustomerAutoOrderShipMethod(Identity.Customer.CustomerID, autoorderid, shipMethodID);

                // Get Partial to update the AutoOrder
                var model   = Exigo.GetCustomerAutoOrder(Identity.Customer.CustomerID, autoorderid);
                var partial = RenderPartialViewToString("displaytemplates/autoorderrow", model);

                return(new JsonNetResult(new
                {
                    success = true,
                    html = partial,
                    autoorderid = autoorderid
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public ActionResult FetchAutoOrderShippingModule(int autoorderid)
        {
            var autoorder = Exigo.GetCustomerAutoOrder(Identity.Customer.CustomerID, autoorderid);

            string html = RenderPartialViewToString("displaytemplates/autoordershippingaddress", autoorder);

            return(new JsonNetResult(new
            {
                success = true,
                module = html
            }));
        }
        public ActionResult UpdateAutoOrderDate(AutoOrderDateViewModel dateVM)
        {
            if (dateVM.NextDate > dateVM.CreatedDate)
            {
                try
                {
                    var autoorderid   = dateVM.AutoorderID;
                    var frequencyType = Exigo.GetFrequencyType((int)dateVM.Frequency);

                    Exigo.UpdateCustomerAutoOrderRunDate(Identity.Customer.CustomerID, autoorderid, dateVM.NextDate, frequencyType);


                    var model   = Exigo.GetCustomerAutoOrder(Identity.Customer.CustomerID, autoorderid);
                    var partial = RenderPartialViewToString("displaytemplates/autoorderrow", model);

                    return(new JsonNetResult(new
                    {
                        success = true,
                        html = partial,
                        autoorderid = autoorderid
                    }));
                }
                catch (Exception ex)
                {
                    return(new JsonNetResult(new
                    {
                        success = false,
                        message = ex.Message
                    }));
                }
            }
            else
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = "Please Select A Valid Date"
                }));
            }
        }
        public ActionResult UpdateAutoOrderShippingAddress(ShippingAddress recipient)
        {
            if (!recipient.IsComplete)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = "Please Enter A CompleteAddress"
                              //message = Resources.Account.PleaseEnterACompleteAddress
                }));
            }

            try
            {
                var autoorderid = Convert.ToInt32(Request.Form["autoorderid"]);

                Exigo.UpdateCustomerAutoOrderShippingAddress(Identity.Customer.CustomerID, autoorderid, recipient);

                // Get Partial to update the AutoOrder
                var model   = Exigo.GetCustomerAutoOrder(Identity.Customer.CustomerID, autoorderid);
                var partial = RenderPartialViewToString("displaytemplates/autoorderrow", model);

                return(new JsonNetResult(new
                {
                    success = true,
                    html = partial,
                    autoorderid = autoorderid
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }