Knocks/BackEnd/Knoks.CryptoExchanges/Data/Dao/ExchangeDao.cs

37 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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; }
}
}
}