public async Task <string> ReLoadAll(string accessToken) { try { if (!Is_Instagram_Sync_Running) { Is_Instagram_Sync_Running = true; //Get all instagram posts var posts = await _IInstagramGraphApi.GetInstagramPosts(accessToken); //Convert instagram posts to TB products ProductsList productsList = ConvertInstagramPostToProducts(posts); //Delete all existing data _ProductsRepository.DeleteAllProducts(); _ProductsRepository.DeleteAllProductsDetails(); //Add products to DB _ProductsRepository.AddProducts(productsList.Products); _ProductsRepository.AddProductsDetails(productsList.ProductsDetails); ////Backup existing images //FTPHandler.BackupDirectory(IMAGES_FOLDER_NAME, ftpUsername, ftpPassword); ////Create images //CreateNewImages(productsList, ftpUsername, ftpPassword); return("Done"); } else { return("Already_Running"); } } finally { Is_Instagram_Sync_Running = false; } }