This commit is contained in:
2023-07-21 21:06:45 +03:00
parent 2f108bef4f
commit fa5a8a9001
37 changed files with 2319 additions and 28 deletions
@@ -1,5 +1,6 @@
namespace MyOffice.Data.Repositories.Currency;
using Microsoft.EntityFrameworkCore;
using Models.Currencies;
public class CurrencyRateRepository : AppRepository<CurrencyRate>, ICurrencyRateRepository
@@ -14,6 +15,20 @@ public class CurrencyRateRepository : AppRepository<CurrencyRate>, ICurrencyRate
.ToList();
}
public List<CurrencyRate> GetLastRates(List<string> currencyIds)
{
return _context.CurrencyRates
.Include(x => x.Currency)
.Where(x => currencyIds.Contains(x.Currency!.CurrencyGlobalId))
.GroupBy(x => new
{
x.CurrencyId,
//x.Currency!.Name,
//x.Currency!.CurrencyGlobalId,
}, (key, g) => g.OrderByDescending(x => x.DateTime).First())
.ToList();
}
public bool AddRate(CurrencyRate currencyRate)
{
return this.AddBase(currencyRate) > 0;