コード例 #1
0
        /// <summary>
        /// Setup user storage with data from the json file database.
        /// Intended use - at server start.
        /// </summary>
        /// <returns>Returns no value.</returns>
        public async void SetupStorage()
        {
            _logger.LogInformation($"{nameof(UsersService)}: Initial setup of the users storage.");
            var data = await _userDataService.ReadJsonArrayAsync(_options.UsersPath);

            foreach (var user in data)
            {
                await _users.AddAsync(ModelsMapper.ToUser(user), user.UserId);
            }

            _logger.LogInformation($"{nameof(UsersService)}: {await _users.CountAsync()} users were added to the users storage.");
        }