fix
This commit is contained in:
@@ -55,6 +55,9 @@ public class RepositoryInitializer
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update all currency - set current rate
|
||||
/// </summary>
|
||||
private static void UpdateCurrentRates(AppDbContext dbContext)
|
||||
{
|
||||
var lastrates = dbContext.CurrencyRates
|
||||
@@ -62,7 +65,7 @@ public class RepositoryInitializer
|
||||
.GroupBy(x => new
|
||||
{
|
||||
x.CurrencyId,
|
||||
}, (key, g) => g.OrderByDescending(x => x.DateTime).First())
|
||||
}, (key, g) => g.Where(x => x.DateTime <= DateTime.UtcNow).OrderByDescending(x => x.DateTime).First())
|
||||
.ToList();
|
||||
|
||||
var currencies = dbContext.Currencies.ToList();
|
||||
@@ -71,8 +74,8 @@ public class RepositoryInitializer
|
||||
var rate = lastrates.FirstOrDefault(x => x.CurrencyId == currency.Id);
|
||||
if (rate != null)
|
||||
{
|
||||
//currency.CurrentRateId = rate.Id;
|
||||
dbContext.Attach(currency);
|
||||
currency.CurrentRateId = rate.Id;
|
||||
dbContext.Attach(currency).State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user