This is it. Don't get scared now. (Converted to Ratermania.Automation)
This commit is contained in:
72
PartSource.Automation/Jobs/Archive/DeleteProducts.cs
Normal file
72
PartSource.Automation/Jobs/Archive/DeleteProducts.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
//using PartSource.Automation.Models;
|
||||
//using PartSource.Data;
|
||||
//using Ratermania.Shopify;
|
||||
//using Ratermania.Shopify.Resources;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace PartSource.Automation.Jobs
|
||||
//{
|
||||
// public class DeleteProducts //: IAutomationJob
|
||||
// {
|
||||
// private readonly ShopifyClient _shopifyClient;
|
||||
// private readonly PartSourceContext _partSourceContext;
|
||||
|
||||
// public DeleteProducts(ShopifyClient shopifyClient, PartSourceContext partSourceContext)
|
||||
// {
|
||||
// _shopifyClient = shopifyClient;
|
||||
// _partSourceContext = partSourceContext;
|
||||
// }
|
||||
|
||||
// // If this job fails, oh well. Run it again and again until it works, or use the Shopify UI (LOL)
|
||||
// public async Task<AutomationJobResult> Run()
|
||||
// {
|
||||
// Console.WriteLine("This job will delete ALL PRODUCTS from Shopify. If you really want to delete EVERY SINGLE PRODUCT, type 'mechanical keyboard' below.");
|
||||
// string input = Console.ReadLine();
|
||||
|
||||
// if (input != "mechanical keyboard")
|
||||
// {
|
||||
// return new AutomationJobResult
|
||||
// {
|
||||
// IsSuccess = true
|
||||
// };
|
||||
// }
|
||||
|
||||
// IList<long?> shopifyIds = _partSourceContext.ImportData
|
||||
// .Select(i => i.ShopifyId)
|
||||
// .Distinct()
|
||||
// .ToList();
|
||||
|
||||
// foreach (long? id in shopifyIds)
|
||||
// {
|
||||
// Product product = await _shopifyClient.Products.GetById((long)id);
|
||||
|
||||
// await _shopifyClient.Products.Delete(product);
|
||||
|
||||
// Console.WriteLine(id);
|
||||
// }
|
||||
|
||||
// //IEnumerable<Product> products = await _shopifyClient.Products.Get();
|
||||
|
||||
// //while (products != null)
|
||||
// //{
|
||||
// // foreach (Product product in products)
|
||||
// // {
|
||||
// // bool result = await _shopifyClient.Products.Delete(product);
|
||||
// // }
|
||||
|
||||
// // products = await _shopifyClient.Products.GetNext();
|
||||
|
||||
// // Console.Write('.');
|
||||
// //}
|
||||
|
||||
// return new AutomationJobResult
|
||||
// {
|
||||
// Message = "All products deleted. Don't forget to truncate the ImportData table",
|
||||
// IsSuccess = true
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user