2017-02-09 04:44:35 +03:00
|
|
|
|
using Bit.App.Abstractions;
|
|
|
|
|
using Plugin.Settings.Abstractions;
|
2017-02-09 07:58:37 +03:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Newtonsoft.Json;
|
2017-02-09 04:44:35 +03:00
|
|
|
|
|
|
|
|
|
namespace Bit.App.Services
|
|
|
|
|
{
|
|
|
|
|
public class SettingsService : ISettingsService
|
|
|
|
|
{
|
|
|
|
|
private readonly ISettingsRepository _settingsRepository;
|
|
|
|
|
private readonly ISettings _settings;
|
2017-02-09 07:58:37 +03:00
|
|
|
|
private readonly IAuthService _authService;
|
2017-02-09 04:44:35 +03:00
|
|
|
|
|
|
|
|
|
public SettingsService(
|
|
|
|
|
ISettingsRepository settingsRepository,
|
2017-02-09 07:58:37 +03:00
|
|
|
|
ISettings settings,
|
|
|
|
|
IAuthService authService)
|
2017-02-09 04:44:35 +03:00
|
|
|
|
{
|
|
|
|
|
_settingsRepository = settingsRepository;
|
|
|
|
|
_settings = settings;
|
2017-02-09 07:58:37 +03:00
|
|
|
|
_authService = authService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<IEnumerable<string>>> GetEquivalentDomainsAsync()
|
|
|
|
|
{
|
|
|
|
|
var settings = await _settingsRepository.GetByIdAsync(_authService.UserId);
|
|
|
|
|
if(string.IsNullOrWhiteSpace(settings?.EquivalentDomains))
|
|
|
|
|
{
|
2017-02-10 06:06:39 +03:00
|
|
|
|
return new List<string[]>();
|
2017-02-09 07:58:37 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JsonConvert.DeserializeObject<IEnumerable<IEnumerable<string>>>(settings.EquivalentDomains);
|
2017-02-09 04:44:35 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|