public async Task UpdateSiteSettingsAsync(int siteId, IEnumerable <SiteSetting> siteSettings) { VerifyManagementPermission(); var currentSiteSettings = await _siteSettingRepository.GetBySiteIdAsync(siteId); var siteSettingsToAdd = siteSettings .Where(_ => currentSiteSettings.Select(s => s.Key).Contains(_.Key) == false); var siteSettingsToRemove = currentSiteSettings .Where(_ => siteSettings.Select(s => s.Key).Contains(_.Key) == false) .Select(_ => _.Id); var siteSettingsToUpdate = siteSettings .Where(_ => currentSiteSettings .Where(s => s.Key == _.Key) .Any(s => s.Value != _.Value)); var userId = GetClaimId(ClaimType.UserId); await _siteSettingRepository.AddListAsync(userId, siteSettingsToAdd); await _siteSettingRepository.RemoveListAsync(userId, siteSettingsToRemove); await _siteSettingRepository.UpdateListAsync(userId, siteSettingsToUpdate); await _siteSettingRepository.SaveAsync(); await _siteLookupService.ReloadSiteCacheAsync(); }