37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Knoks.CryptoExchanges.Data.Interfaces;
|
||
using Knoks.CryptoExchanges.Entities;
|
||
using Knoks.Framework.DataAccess;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace Knoks.CryptoExchanges.Data.Dao
|
||
{
|
||
public class ExchangeDao : IExchangeDao
|
||
{
|
||
private IProcExecutor executor;
|
||
public ExchangeDao(IProcExecutor executor)
|
||
{
|
||
this.executor = executor;
|
||
}
|
||
public async Task<IEnumerable<Exchange>> GetExchanges(int? exchangeId = null)
|
||
{
|
||
return (await executor.Go(DatabaseNames.Prices, "GetExchanges", new { ExchangeId = exchangeId })).Тables[0].ToList<ExchangeData>().GroupBy(it => new { id = it.ExchangeId, name = it.ExchangeName }).Select(it => new Exchange()
|
||
{
|
||
ExchangeId = it.Key.id,
|
||
ExchangeName = it.Key.name,
|
||
});
|
||
}
|
||
|
||
private class ExchangeData
|
||
{
|
||
public short ExchangeId { get; set; }
|
||
public string ExchangeName { get; set; }
|
||
//public string Currency1 { get; set; }
|
||
//public string Currency2 { get; set; }
|
||
//public string Currency { get; set; }
|
||
//public string TickerDisplayName { get; set; }
|
||
}
|
||
}
|
||
}
|