Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from Azure-Samples/bogavril/cleanup
Browse files Browse the repository at this point in the history
Code cleanup and solution file
  • Loading branch information
mmacy authored Mar 10, 2020
2 parents 10f8674 + e67dd11 commit 4c96e99
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 39 deletions.
25 changes: 25 additions & 0 deletions b2c-ms-graph.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29827.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "b2c-ms-graph", "src\b2c-ms-graph.csproj", "{0ABAE601-9B40-49F8-8379-0B07A521FCFF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0ABAE601-9B40-49F8-8379-0B07A521FCFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0ABAE601-9B40-49F8-8379-0B07A521FCFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0ABAE601-9B40-49F8-8379-0B07A521FCFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0ABAE601-9B40-49F8-8379-0B07A521FCFF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7DED9967-ECF2-457B-99F4-716E39C5CD96}
EndGlobalSection
EndGlobal
47 changes: 8 additions & 39 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,9 @@

namespace b2c_ms_graph
{
class Program
public static class Program
{
static void Main(string[] args)
{
try
{
RunAsync().GetAwaiter().GetResult();
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
Console.ResetColor();
}
}

private static async Task RunAsync()
static async Task Main(string[] args)
{
// Read application settings from appsettings.json (tenant ID, app ID, client secret, etc.)
AppSettings config = AppSettingsFile.ReadFromJsonFile();
Expand All @@ -41,7 +27,7 @@ private static async Task RunAsync()
// Set up the Microsoft Graph service client with client credentials
GraphServiceClient graphClient = new GraphServiceClient(authProvider);

Program.PrintCommands();
PrintCommands();

try
{
Expand All @@ -52,13 +38,13 @@ private static async Task RunAsync()
switch (decision.ToLower())
{
case "1":
await UserService.ListUsers(graphClient); ;
await UserService.ListUsers(graphClient);
break;
case "2":
await UserService.GetUserById(graphClient); ;
await UserService.GetUserById(graphClient);
break;
case "3":
await UserService.GetUserBySignInName(config, graphClient); ;
await UserService.GetUserBySignInName(config, graphClient);
break;
case "4":
await UserService.DeleteUserById(graphClient);
Expand Down Expand Up @@ -87,26 +73,9 @@ private static async Task RunAsync()
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;

var innerException = ex.InnerException;
if (innerException != null)
{
while (innerException != null)
{
Console.WriteLine(innerException.Message);
innerException = innerException.InnerException;
}
}
else
{
Console.WriteLine(ex.Message);
}
}
finally
{
Console.WriteLine($"An error occurred: {ex}");
Console.ResetColor();
}

}
Console.ReadLine();
}

Expand Down

0 comments on commit 4c96e99

Please sign in to comment.