static void ProductTypeSync() { Console.WriteLine("--- Start to access ProductType ---"); List <ProductType> dbProductType = GetProductType(); List <ProductType> ProductType = new List <ProductType>(); Company[] companyList = OS_sellerCloud.ListAllCompany(OS_authHeader, OS_options); foreach (Company company in companyList) { ProductType.AddRange(OS_sellerCloud.ListProductType(OS_authHeader, OS_options, company.ID) .Select(t => new ProductType() { IsEnable = true, ID = t.ID, ProductTypeName = t.ProductTypeName }).ToArray()); } Console.WriteLine("--- Get <" + ProductType.Count() + "> ProductType from Sellercloud ---"); Console.WriteLine("--- End to access ProductType ---"); IEnumerable <ProductType> newProductType = ProductType.Except(dbProductType); Console.WriteLine("--- There are <" + newProductType.Count() + "> new ProductType ---"); if (newProductType.Any()) { DataProcess.BulkInsert(conn, "ProductType", newProductType.ToList()); } }
public ProductType[] Get_ProductType(int CompanyID) { return(OS_SellerCloud.ListProductType(OS_AuthHeader, OS_Options, CompanyID)); }