static void Main(string[] args)
{
try
{
_serviceUri = new Uri("https://" + ConfigurationManager.AppSettings["SearchServiceName"] + ".search.windows.net");
_httpClient = new HttpClient();
_httpClient.DefaultRequestHeaders.Add("api-key", ConfigurationManager.AppSettings["SearchServiceApiKey"]);
if(CatalogIndexExists())
{
Console.WriteLine("Index already exists. Re-create (y/n)?");
string resp = Console.ReadLine();
if(resp == "y")
{
DeleteCatalogIndex();
new SearchRepository().EnsureStorageCreated().Wait();
Console.WriteLine("Index created");
}
}
else
{
new SearchRepository().EnsureStorageCreated().Wait();
Console.WriteLine("Index created");
}
Console.WriteLine("Number of test customers to add?");
string resp3 = Console.ReadLine();
int num;
if(int.TryParse(resp3, out num))
{
AddTestCustomers(num);
}
Console.WriteLine("Add test data (y/n)?");
string resp2 = Console.ReadLine();
if (resp2 == "y")
{
AddTestData();
}
}
catch (Exception e)
{
Console.WriteLine("Unhandled exception caught:");
while (e != null)
{
Console.WriteLine("\t{0}", e.Message);
e = e.InnerException;
}
Console.WriteLine();
}
Console.Write("Complete. Press <enter> to continue: ");
var name = Console.ReadLine();
}