fix
This commit is contained in:
@@ -32,13 +32,15 @@ public class CurrencyController : BaseApiController
|
||||
{
|
||||
var list = _currencyService.GetAllWithRates(UserId);
|
||||
|
||||
return list.Select(x => x.Key.ToModel(x.Value));
|
||||
return list
|
||||
.OrderBy(x => x.Key.CurrencyGlobalId)
|
||||
.Select(x => x.Key.ToModel(x.Value));
|
||||
}
|
||||
|
||||
[HttpPost("~/api/settings/currencies")]
|
||||
public object Post(CurrencyAddModel currency)
|
||||
{
|
||||
var exec = _currencyService.AddCurrency(UserId, new Currency
|
||||
var exec = _currencyService.CurrencyAdd(UserId, new Currency
|
||||
{
|
||||
UserId = UserId,
|
||||
CurrencyGlobalId = currency.Id,
|
||||
@@ -48,9 +50,9 @@ public class CurrencyController : BaseApiController
|
||||
|
||||
switch (exec.Status)
|
||||
{
|
||||
case AddCurrencyStatus.success:
|
||||
case AddCurrencyStatus.exists:
|
||||
_currencyService.AddCurrencyRate(UserId, exec.Result!.Id, new CurrencyRate()
|
||||
case CurrencyAddStatus.success:
|
||||
case CurrencyAddStatus.exists:
|
||||
_currencyService.CurrencyRateAdd(UserId, exec.Result!.Id, new CurrencyRate()
|
||||
{
|
||||
CurrencyId = exec.Result!.Id,
|
||||
Rate = currency.Rate,
|
||||
@@ -59,7 +61,7 @@ public class CurrencyController : BaseApiController
|
||||
});
|
||||
return currency;
|
||||
|
||||
case AddCurrencyStatus.failed:
|
||||
case CurrencyAddStatus.failed:
|
||||
return ProblemBadRequest("Adding currency failed.");
|
||||
|
||||
default:
|
||||
@@ -67,10 +69,33 @@ public class CurrencyController : BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("~/api/settings/currencies/{id}")]
|
||||
public object Put(string id, CurrencyEditModel currency)
|
||||
{
|
||||
var exec = _currencyService.CurrencyUpdate(
|
||||
UserId,
|
||||
id.AsGuid(),
|
||||
new CurrencyEdit { Name = currency.Name, ShortName = currency.ShortName }
|
||||
);
|
||||
|
||||
switch (exec.Status)
|
||||
{
|
||||
case CurrencyEditStatus.success:
|
||||
return exec.Result!.ToModel();
|
||||
|
||||
case CurrencyEditStatus.not_found:
|
||||
case CurrencyEditStatus.failed:
|
||||
return ProblemBadRequest("Currency not found.");
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("~/api/settings/currencies/{id}/rate")]
|
||||
public object Post(string id, CurrencyRateModel currencyRate)
|
||||
{
|
||||
var exec = _currencyService.AddCurrencyRate(UserId, id.AsGuid(), new CurrencyRate()
|
||||
var exec = _currencyService.CurrencyRateAdd(UserId, id.AsGuid(), new CurrencyRate()
|
||||
{
|
||||
CurrencyId = id.AsGuid(),
|
||||
Quantity = currencyRate.Quantity,
|
||||
|
||||
Reference in New Issue
Block a user