public async Task DeleteSite() { var client = await authenticator.GetAuthenticatedClient(); var sites = await siteSelector.DisplaySite(client); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Enter the Id of the site you want to delete: "); var siteId = Convert.ToInt32(Console.ReadLine()); var site = sites.Single(x => x.Id == siteId); Console.WriteLine("Chosen Site: "); ConsoleTable .From(new List <Site> { site }) .Write(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Are you sure you want to delete this site?"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Type YES if you confirm:"); var response = Console.ReadLine(); if (response != null && response.Equals("YES", StringComparison.InvariantCultureIgnoreCase)) { Console.WriteLine(); Console.WriteLine("WARNING: This action cannot be undone, please enter the Site Id to validate:"); var confirmId = Convert.ToInt32(Console.ReadLine()); if (confirmId == siteId) { await InternalDeleteSite(client, siteId); } else { Console.WriteLine("The site id you typed is different. Abording the request."); } } }
private async Task <Source[]> InternalDisplaySource(HttpClient client, bool fromSite = false) { int?siteId = null; if (fromSite) { await siteSelector.DisplaySite(client); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Enter the Id of the site you want to select: "); siteId = Convert.ToInt32(Console.ReadLine()); } var sources = await GetSources(client, siteId); ConsoleTable .From(sources) .Write(); return(sources); }