fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
namespace MyOffice.Services.Currency;
|
||||
|
||||
using Core;
|
||||
using Core.Extensions;
|
||||
using Data.Models.Currencies;
|
||||
using Data.Repositories.Currency;
|
||||
using MyOffice.Services.Currency.Domain;
|
||||
@@ -37,7 +38,7 @@ public class CurrencyService
|
||||
var list = _currencyRepository.GetAll(userId);
|
||||
return list.ToDictionary(
|
||||
x => x,
|
||||
x => _currencyRateRepository.GetLastRates(x.Id, 1).FirstOrDefault()
|
||||
x => _currencyRateRepository.GetLastRates(x.Id).FirstOrDefault()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,13 +114,13 @@ public class CurrencyService
|
||||
|
||||
var result = new Exec<CurrencyRate, CurrencyAddRateStatus>(CurrencyAddRateStatus.success);
|
||||
|
||||
var exists = _currencyRepository.Get(userId, currencyId);
|
||||
if (exists == null)
|
||||
var currency = _currencyRepository.Get(userId, currencyId);
|
||||
if (currency == null)
|
||||
{
|
||||
return result.Set(CurrencyAddRateStatus.not_found);
|
||||
}
|
||||
|
||||
currencyRate.CurrencyId = exists.Id;
|
||||
currencyRate.CurrencyId = currency.Id;
|
||||
currencyRate.DateTime = currencyRate.DateTime.Date;
|
||||
|
||||
var rates = _currencyRateRepository.GetAtDate(currencyRate.CurrencyId, currencyRate.DateTime);
|
||||
@@ -132,6 +133,12 @@ public class CurrencyService
|
||||
}
|
||||
|
||||
rate = currencyRate;
|
||||
|
||||
if (rate.DateTime.EndOfDay() <= DateTime.UtcNow.EndOfDay())
|
||||
{
|
||||
currency.CurrentRateId = rate.Id;
|
||||
_currencyRepository.Update(currency);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Set(rate);
|
||||
|
||||
Reference in New Issue
Block a user