fix
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -41,4 +41,9 @@ public class CurrencyRepository : AppRepository<Currency>, ICurrencyRepository
|
||||
{
|
||||
return RemoveBase(currency) > 0;
|
||||
}
|
||||
|
||||
public List<Currency> GetPrimaries(Guid userId)
|
||||
{
|
||||
return _context.Currencies.Where(x => x.UserId == userId && x.IsPrimary).ToList();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Models.Currencies;
|
||||
public interface ICurrencyRateRepository
|
||||
{
|
||||
List<CurrencyRate> GetLastRates(Guid currencyId, int count = 1);
|
||||
List<CurrencyRate> GetLastRates(List<string> currencyIds);
|
||||
bool AddRate(CurrencyRate currencyRate);
|
||||
List<CurrencyRate> GetAtDate(Guid currencyId, DateTime date);
|
||||
}
|
||||
@@ -10,4 +10,5 @@ public interface ICurrencyRepository
|
||||
bool Add(Currency currency);
|
||||
bool Update(Currency currency);
|
||||
bool Remove(Currency currency);
|
||||
List<Currency> GetPrimaries(Guid userId);
|
||||
}
|
||||
Reference in New Issue
Block a user