Esempio n. 1
0
        public async Task <List <Watcher> > UpdateWatchers(List <Watcher> defaultWatchers)
        {
            // Start watch
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            // Get all watchers
            var watchers = await _mainDbContext.Watchers.Where(WatcherExpression.NonDefaultWatcher()).ToListAsync();

            // Sync watchers
            watchers.SyncWatchers(defaultWatchers);

            // Update
            _mainDbContext.Watchers.UpdateRange(watchers);

            // Save
            await _mainDbContext.SaveChangesAsync();

            // Stop watch
            stopwatch.Stop();

            // Log
            _logger.LogInformation("{@Event}, {@Count}, {@ExecutionTime}", "WatchersUpdated", watchers.Count, stopwatch.Elapsed.TotalSeconds);

            // Return
            return(watchers);
        }