static void Main(string[] args)
        {
            var adapter  = new ConsoleAdapter();
            var services = new ServiceCollection()
                           .AddLogging();

            IConfiguration Configuration = new ConfigurationBuilder()
                                           //Custom Code Start | Replaced Code Block
                                           //Replaced Code Block Start
                                           //.AddJsonFile(@"C:\xInventory\xInventoryDev75\WebCore\BotSpiel\BotSpiel\appsettings.json", true, true)
                                           //Replaced Code Block End
                                           .AddJsonFile(@"C:\Software\SourceBotSpielInventory\WebCore\BotSpiel\BotSpiel\appsettings.json", true, true)
                                           //Custom Code End
                                           .Build();

            BotSpielModule.LoadModule(services, Configuration);
            services.AddTransient <BotUserData>();
            services.AddSingleton(new ApplicationDbContext(
                                      new DbContextOptionsBuilder <ApplicationDbContext>().UseSqlServer(Configuration.GetConnectionString("DefaultConnection")).Options)
                                  );

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            var serviceProvider = services.BuildServiceProvider();
            var ILoggerService  = serviceProvider.GetService <ILoggerFactory>();
            var logger          = ILoggerService.CreateLogger <BotSpielBot>();

            IStorage dataStore         = new MemoryStorage();
            var      conversationState = new ConversationState(dataStore);
            var      userState         = new UserState(dataStore);
            var      accessors         = new BotSpielUserStateAccessors(conversationState, userState)
            {
                DialogStateAccessor = conversationState.CreateProperty <DialogState>(BotSpielUserStateAccessors.DialogStateAccessorName),
                DidBotWelcomeUser   = userState.CreateProperty <bool>(BotSpielUserStateAccessors.DidBotWelcomeUserName),
                BotUserDataAccessor = userState.CreateProperty <BotUserData>(BotSpielUserStateAccessors.BotUserDataAccessorName),
            };


            //Custom Code Start | Added Code Block
            var _userManager = serviceProvider.GetService <UserManager <ApplicationUser> >();
            //Custom Code End

            var consoleBot = new BotSpielBot(serviceProvider.GetRequiredService <ILoggerFactory>(), accessors, serviceProvider.GetRequiredService <BotUserData>(), serviceProvider.GetRequiredService <BotUserEntityContext>(), serviceProvider.GetRequiredService <NavigationEntityData>()
                                             , serviceProvider.GetRequiredService <DropInventoryUnitsPost>()
                                             , serviceProvider.GetRequiredService <PickBatchPickingPost>()
                                             , serviceProvider.GetRequiredService <PutAwayHandlingUnitsPost>()
                                             , serviceProvider.GetRequiredService <SetUpExecutionParametersPost>()
                                             , serviceProvider.GetRequiredService <IPutAwayHandlingUnitsService>()
                                             , serviceProvider.GetRequiredService <ISetUpExecutionParametersService>()
                                             , serviceProvider.GetRequiredService <IHandlingUnitsService>()
                                             , _userManager
                                             , serviceProvider.GetRequiredService <IFacilitiesService>()
                                             , serviceProvider.GetRequiredService <PutAway>()
                                             , serviceProvider.GetRequiredService <IInventoryLocationsService>()
                                             , serviceProvider.GetRequiredService <ILocationFunctionsService>()
                                             , serviceProvider.GetRequiredService <IMoveQueueTypesService>()
                                             , serviceProvider.GetRequiredService <IMoveQueueContextsService>()
                                             , serviceProvider.GetRequiredService <IInventoryUnitsService>()
                                             , serviceProvider.GetRequiredService <IStatusesService>()
                                             , serviceProvider.GetRequiredService <IMoveQueuesService>()
                                             , serviceProvider.GetRequiredService <IPickBatchesService>()
                                             , serviceProvider.GetRequiredService <CommonLookUps>()
                                             , serviceProvider.GetRequiredService <Picking>()
                                             , serviceProvider.GetRequiredService <Shipping>()
                                             , serviceProvider.GetRequiredService <IPickBatchPickingService>()
                                             , serviceProvider.GetRequiredService <IOutboundOrderLinesInventoryAllocationService>()
                                             , serviceProvider.GetRequiredService <IOutboundOrderLinePackingService>()

                                             );

            //Custom Code Start | Removed Block
            //Console.WriteLine("Hello. Please type something to get us started.");
            //Custom Code End

            //Custom Code Start | Added Code Block
            Console.WriteLine(@"Hi. Enter your 
username/email.");
            //Custom Code End

            var UserName = Console.ReadLine();

            //var user = _userManager.FindByEmailAsync(UserName);
            //var debuf = _userManager.Users.Where(x => x.UserName == UserName).Count();
            //Console.WriteLine(user.Result.Email);

            adapter.ProcessActivityAsync(
                async(turnContext, cancellationToken) => await consoleBot.OnTurnAsync(turnContext)).Wait();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            // Add application services.
            services.AddTransient <IEmailSender, EmailSender>();
            services.AddDataProtection();

            BotSpielModule.LoadModule(services, Configuration);
            services.AddTransient <BotUserData>();
            //Custom Code Start | Replaced Code Block
            //Replaced Code Block Start
            //            services.AddMvc();
            //Replaced Code Block End
            services.AddMvc().AddFluentValidation();
            //Custom Code End
            services.AddMvcGrid();

            services.AddBot <BotSpielBot>(options =>
            {
                var secretKey   = Configuration.GetSection("botFileSecret")?.Value;
                var botFilePath = Configuration.GetSection("botFilePath")?.Value;

                // Loads .bot configuration file and adds a singleton that your Bot can access through dependency injection.
                var botConfig = BotConfiguration.Load(botFilePath ?? @".\BotConfiguration.bot", secretKey);
                services.AddSingleton(sp => botConfig ?? throw new InvalidOperationException($"The .bot config file could not be loaded. ({botConfig})"));

                // Retrieve current endpoint.
                var environment = _isProduction ? "production" : "development";
                var service     = botConfig.Services.Where(s => s.Type == "endpoint" && s.Name == environment).FirstOrDefault();
                if (!(service is EndpointService endpointService))
                {
                    throw new InvalidOperationException($"The .bot file does not contain an endpoint with name '{environment}'.");
                }

                options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword);

                // Creates a logger for the application to use.
                ILogger logger = _loggerFactory.CreateLogger <BotSpielBot>();

                // Catches any errors that occur during a conversation turn and logs them.
                options.OnTurnError = async(context, exception) =>
                {
                    logger.LogError($"Exception caught : {exception}");
                    await context.SendActivityAsync("Sorry, it looks like something went wrong.");
                };

                // The Memory Storage used here is for local bot debugging only. When the bot
                // is restarted, anything stored in memory will be gone.
                IStorage dataStore = new MemoryStorage();

                // The Conversation State object is where we persist anything at the conversation-scope.
                var conversationState = new ConversationState(dataStore);
                options.State.Add(conversationState);

                // Create and add user state.
                var userState = new UserState(dataStore);
                options.State.Add(userState);
            });

            // Create and register state accesssors.
            // Accessors created here are passed into the IBot-derived class on every turn.
            services.AddSingleton <BotSpielUserStateAccessors>(sp =>
            {
                var options = sp.GetRequiredService <IOptions <BotFrameworkOptions> >().Value;
                if (options == null)
                {
                    throw new InvalidOperationException("BotFrameworkOptions must be configured prior to setting up the State Accessors");
                }

                var conversationState = options.State.OfType <ConversationState>().FirstOrDefault();
                if (conversationState == null)
                {
                    throw new InvalidOperationException("ConversationState must be defined and added before adding conversation-scoped state accessors.");
                }

                var userState = options.State.OfType <UserState>().FirstOrDefault();
                if (userState == null)
                {
                    throw new InvalidOperationException("UserState must be defined and added before adding user-scoped state accessors.");
                }

                // Create the custom state accessor.
                // State accessors enable other components to read and write individual properties of state.
                var accessors = new BotSpielUserStateAccessors(conversationState, userState)
                {
                    DialogStateAccessor = conversationState.CreateProperty <DialogState>(BotSpielUserStateAccessors.DialogStateAccessorName),
                    DidBotWelcomeUser   = userState.CreateProperty <bool>(BotSpielUserStateAccessors.DidBotWelcomeUserName),
                    BotUserDataAccessor = userState.CreateProperty <BotUserData>(BotSpielUserStateAccessors.BotUserDataAccessorName),
                };

                return(accessors);
            });
        }