示例#1
0
        public async Task InitializeAsync()
        {
            using (IServiceScope scope = _scopeFactory.CreateScope())
            {
                ApplicationDbContext db = scope.GetDatabase();

                await db.Database.EnsureCreatedAsync();

                await db.Users
                .ToAsyncEnumerable()
                .ForEachAwaitAsync(Login);

                if (db.OperatedPosts != null)
                {
                    await db.OperatedPosts
                    .ToAsyncEnumerable()
                    .ForEachAsync(
                        post => _postOperationValidator.UserOperatedOnPost(post.PostId, post.UserId));
                }

                if (db.WatchedUsers != null)
                {
                    var watchedUsers = await db.WatchedUsers.ToListAsync();

                    _postsChecker
                    .WatchedUsers
                    .AddRange(watchedUsers);
                }
            }

            _postOperationValidator
            .OnUserOperatedOnPost
            .SubscribeAsync(OnUserOperatedOnPost);

            _postsWatcher.StartWatch();
        }
        public IActionResult CheckManually(string returnUrl)
        {
            _postsWatcher.StartWatch();

            return(Redirect(returnUrl));
        }