public async Task <bool> SyncOrders(string shopname, string token, string serverurl, int duration)
        {
            bool response = true;

            try
            {
                string           shopifyurl = $"https://{shopname}.myshopify.com/";
                var              client     = new HttpClient();
                OrderDetailModel model      = new OrderDetailModel();
                model.shopifyurl = shopifyurl;
                model.token      = token;
                model.duration   = duration;
                List <Order> orders = await GetAllOrders(model);

                string json = JsonConvert.SerializeObject(orders);
                List <OrderReturnModel> orderReturns = await GetOrderReturnModel(orders, shopname);

                string apiUrl2   = $"{serverurl}/api/AddShopifyOrders";
                var    response2 = client.PostAsJsonAsync(apiUrl2, orderReturns).Result;
                response2.EnsureSuccessStatusCode();
                string responseBody1 = await response2.Content.ReadAsStringAsync();

                var readString = JObject.Parse(responseBody1)["status"];
                response = Convert.ToBoolean(readString.ToString());
            }
            catch (Exception)
            {
                throw;
            }
            return(response);
        }
        public async Task <List <Order> > GetAllOrders(OrderDetailModel model)
        {
            string       msg;
            List <Order> Orders = new List <Order>();

            try
            {
                var allOrders = new List <Order>();
                var service   = new OrderService(model.shopifyurl, model.token);
                //if (model.duration == 0)
                //{
                //    model.duration = 3;
                //}
                var page = await service.ListAsync(new OrderListFilter
                {
                    Limit             = 250,
                    FulfillmentStatus = "Unfulfilled",
                    FinancialStatus   = "paid",
                    CreatedAtMin      = DateTime.Today.AddDays(-model.duration),
                    CreatedAtMax      = DateTime.Now
                });

                while (true)
                {
                    allOrders.AddRange(page.Items);

                    if (!page.HasNextPage)
                    {
                        break;
                    }

                    page = await service.ListAsync(page.GetNextPageFilter());
                }
                Orders = allOrders;
            }
            catch (Exception ex)
            {
                msg = ex.Message.ToString();
            }
            return(Orders);
        }