예제 #1
0
        public async Task <dynamic> Get(string companyName)
        {
            DateTime operationStarted = DateTime.Now;

            using (HttpClient client = new HttpClient())
                using (Entities db = new Entities())
                {
                    var result = await BulkAction.PerformBulkAction(client, companyName, db, ConfigDictionary.Config()["ShopifyAdminAPIVersion"]);

                    if (Equals(result.GetType(), typeof(string)))
                    {
                        return(BulkAction.WriteSalesData(result,
                                                         db
                                                         .StoreCustomDatas
                                                         .Where(x => x.StoreName == companyName)
                                                         .FirstOrDefault()
                                                         .StoreID,
                                                         db,
                                                         operationStarted));
                    }
                    else
                    {
                        return(result);
                    }
                }
        }
예제 #2
0
        public async Task <dynamic> Get(string companyName)
        {
            if (CheckClientSecret())
            {
                DateTime operationStarted = DateTime.Now;

                Entities db = new Entities();

                using (HttpClient client = new HttpClient())
                {
                    var result = await BulkAction.PerformBulkAction(client, companyName, db, ConfigDictionary.Config()["ShopifyAdminAPIVersion"]);

                    if (Equals(result.GetType(), typeof(string)))
                    {
                        StoreCustomData store = db.StoreCustomDatas.FirstOrDefault(x => x.StoreName == companyName);

                        var dbResult = BulkAction.WriteSalesData(result,
                                                                 store.StoreID,
                                                                 db,
                                                                 operationStarted);

                        if (!Equals(dbResult.GetType(), typeof(Exception)))
                        {
                            return(db.SalesDatas.Where(x => x.StoreID == store.StoreID).OrderBy(x => x.Date));
                        }
                        else
                        {
                            return(new ArgumentException("An error occurred while writing to the database."));
                        }
                    }
                    else
                    {
                        return(result);
                    }
                }
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.Forbidden));
            }
        }