private static void AddTelegramDbContext(this IServiceCollection services,
                                                 TelegramNpuOptions options)
        {
            if (options.UseInMemoryDb)
            {
                services.AddDbContext <TelegramDbContext>(builder =>
                                                          builder.UseInMemoryDatabase("npurozklad"));
            }
            else
            {
                services.AddDbContext <TelegramDbContext>(builder =>
                                                          builder.UseMySql(options.ConnectionString, optionsBuilder =>
                                                                           optionsBuilder
                                                                           .EnableRetryOnFailure(10)
                                                                           .MigrationsHistoryTable("telegram-migrations")));

                var provider  = services.BuildServiceProvider();
                var dbContext = provider.GetService <TelegramDbContext>();

                dbContext.Database.Migrate();
            }
        }
        public static IServiceCollection AddTelegramNpu(this IServiceCollection services,
                                                        Action <TelegramNpuOptions> telegramNpuOptionsBuilder)
        {
            var options = new TelegramNpuOptions();

            telegramNpuOptionsBuilder(options);

            services.AddScoped <ResetCurrentUserAction>();
            services.AddScoped <ShowApplicationVersionAction>();
            services.AddScoped <ShowFacultyGroupsForFacultyDoesNotExistMessageAction>();
            services.AddScoped <ShowMessageAction>();
            services.AddScoped <ShowMainMenuAction>();
            services.AddScoped <ShowTimetableFacultyGroupsMenuAction>();
            services.AddScoped <ShowTimetableFacultyGroupViewMenuAction>();
            services.AddScoped <ShowTimetableSelectingFacultyGroupToAddMenuAction>();
            services.AddScoped <ShowTimetableSelectingFacultyMenuAction>();
            services.AddScoped <ShowTimetableFacultyGroupsRemoveMenuAction>();

            services.AddSingleton <IFacultyGroupsInlineMenuCreator, FacultyGroupsInlineMenuCreator>();
            services.AddSingleton <KeyboardMarkupMenuCreator>();
            services.AddSingleton <BackInlineButtonCreator>();
            services.AddSingleton <InlineKeyboardButtonsCreator>();
            services.AddSingleton <MainMenuCreator>();
            services.AddScoped <OneDayLessonsToTelegramMessageText>();
            services.AddScoped <TimetableFacultyGroupsKeyboardCreator>();
            services.AddScoped <TimetableFacultyListKeyboardCreator>();
            services.AddScoped <DayOfWeekInlineButtonsCreator>();
            services.AddScoped <TimetableFacultyGroupViewInlineMenuCreator>();
            services.AddScoped <WeekSelectorInlineButtonsCreator>();
            services.AddScoped <TimetableFacultyGroupsMenu>();
            services.AddTransient <TimetableFacultyGroupsRemoveMenu>();

            services.AddScoped <ITelegramUpdateHandler, TelegramUpdateHandler>();
            services.AddSingleton <ICallbackQueryHandler, CallbackQueryGlobalHandler>();
            services.AddSingleton <ITelegramMessageHandler, TelegramMessageGlobalHandler>();
            services.AddSingleton <AddGroupCallbackHandler>();
            services.AddSingleton <ShowTimetableFacultyGroupsMenuCallbackHandler>();
            services.AddTransient <ShowTimetableFacultyGroupViewMenuCallbackHandler>();
            services.AddSingleton <SpecificCallbackQueryHandlerProvider>();
            services.AddSingleton <CommandHandler>();
            services.AddSingleton <LongLastingUserActionGeneralHandler>();
            services.AddSingleton <MessageTextHandler>();

            services.AddSingleton <ILongLastingUserActionHandlerFactory, LongLastingUserActionHandlerFactory>();
            services.AddSingleton <ILongLastingUserActionManager, LongLastingUserActionManager>();

            services.AddScoped <ITelegramRozkladUserDao, TelegramRozkladUserDao>();

            services.AddScoped <ICurrentTelegramUserContext, CurrentTelegramUserContext>();
            services.AddTransient <ICurrentUserInitializerService, CurrentUserInitializerService>();
            services.AddScoped <ICurrentScopeMessageIdProvider, CurrentScopeMessageIdProvider>();
            services.AddSingleton <ICurrentUserLocalizationService, CurrentUserLocalizationService>();
            services.AddSingleton <ICurrentTelegramUserProvider, CurrentTelegramUserProvider>();
            services.AddSingleton <ITelegramUserThrottle, TelegramUserThrottle>();
            services.AddTelegramBotClient(options.BotApiToken);
            services.AddSingleton <ITelegramBotActions, TelegramBotActions>();
            services.AddTransient <TimetableSelectingFacultyActionHandler>();
            services.AddTransient <TimetableSelectingFacultyGroupToAddActionHandler>();
            services.AddTransient <TimetableFacultyGroupsMenuGroupSelectedHandler>();
            services.AddTransient <OpenRemoveGroupsMenuCallbackHandler>();
            services.AddTransient <RemoveGroupCallbackHandler>();

            services.AddTelegramDbContext(options);

            return(services);
        }