2010-11-02 16:26:36 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using MonoStockPortfolio.Core.Services;
|
|
|
|
using MonoStockPortfolio.Core.Config;
|
2011-01-02 01:16:08 +00:00
|
|
|
using MonoStockPortfolio.Entities;
|
2010-11-02 16:26:36 +00:00
|
|
|
|
|
|
|
namespace MonoStockPortfolio.Core.Config
|
|
|
|
{
|
|
|
|
public class ConfigManager
|
|
|
|
{
|
|
|
|
public class Config
|
|
|
|
{
|
|
|
|
public Config()
|
|
|
|
{
|
|
|
|
StockDetailItems = new List<StockDataItem>();
|
|
|
|
}
|
|
|
|
public IList<StockDataItem> StockDetailItems { get; set; }
|
|
|
|
public bool AgreedToTermsOfService { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
private IConfigRepository _repo;
|
|
|
|
private Config _config;
|
|
|
|
|
|
|
|
public ConfigManager() : this(new AndroidSqliteConfigRepository()) {}
|
|
|
|
|
|
|
|
public ConfigManager(IConfigRepository repository)
|
|
|
|
{
|
|
|
|
_repo = repository;
|
|
|
|
_config = _repo.LoadOrCreateConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool AgreedToTos
|
|
|
|
{
|
|
|
|
get {
|
|
|
|
return _config.AgreedToTermsOfService;
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_config.AgreedToTermsOfService = value;
|
|
|
|
_repo.SaveConfig(_config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateStockDetailItems(IList<StockDataItem> newStockDetailItems)
|
|
|
|
{
|
|
|
|
_config.StockDetailItems = newStockDetailItems;
|
|
|
|
_repo.SaveConfig(_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<StockDataItem> GetStockDetailItems()
|
|
|
|
{
|
|
|
|
return _config.StockDetailItems;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|