29 lines
709 B
C#
29 lines
709 B
C#
namespace MyOffice.Data.Repositories.Currency;
|
|
|
|
using Models.Currencies;
|
|
|
|
public class CurrencyRateRepository : AppRepository<CurrencyRate>, ICurrencyRateRepository
|
|
{
|
|
public List<CurrencyRate> GetLastRates(Guid currencyId, int count = 1)
|
|
{
|
|
return _context.CurrencyRates
|
|
.Where(x => x.CurrencyId == currencyId)
|
|
.OrderByDescending(x => x.DateTime)
|
|
.ThenByDescending(x => x.Id)
|
|
.Take(count)
|
|
.ToList();
|
|
}
|
|
|
|
public bool AddRate(CurrencyRate currencyRate)
|
|
{
|
|
return this.AddBase(currencyRate) > 0;
|
|
}
|
|
|
|
public List<CurrencyRate> GetAtDate(Guid currencyId, DateTime date)
|
|
{
|
|
return _context.CurrencyRates
|
|
.Where(x => x.CurrencyId == currencyId && x.DateTime == date)
|
|
.ToList();
|
|
|
|
}
|
|
} |