This commit is contained in:
2023-07-21 23:01:56 +03:00
parent fa5a8a9001
commit d0cdaa85b6
18 changed files with 863 additions and 178 deletions
@@ -5,10 +5,13 @@ using Models.Currencies;
public class CurrencyRateRepository : AppRepository<CurrencyRate>, ICurrencyRateRepository
{
public List<CurrencyRate> GetLastRates(Guid currencyId, int count = 1)
public List<CurrencyRate> GetLastRates(Guid currencyId, DateTime? before = null, int count = 1)
{
before = before ?? DateTime.UtcNow;
return _context.CurrencyRates
.Where(x => x.CurrencyId == currencyId)
.Where(x => x.DateTime <= before)
.OrderByDescending(x => x.DateTime)
.ThenByDescending(x => x.Id)
.Take(count)
@@ -4,7 +4,7 @@ using Models.Currencies;
public interface ICurrencyRateRepository
{
List<CurrencyRate> GetLastRates(Guid currencyId, int count = 1);
List<CurrencyRate> GetLastRates(Guid currencyId, DateTime? before = null, int count = 1);
List<CurrencyRate> GetLastRates(List<string> currencyIds);
bool AddRate(CurrencyRate currencyRate);
List<CurrencyRate> GetAtDate(Guid currencyId, DateTime date);