This commit is contained in:
2023-08-04 17:53:15 +03:00
parent cf89dd6a4d
commit 70edf34cf6
17 changed files with 236 additions and 86 deletions
@@ -1,8 +1,10 @@
namespace MyOffice.Web.Controllers;
using AutoMapper;
using Core;
using Core.Extensions;
using Data.Models.Currencies;
using Infrastructure.Attributes;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Models.Currency;
@@ -92,6 +94,25 @@ public class CurrencyController : BaseApiController
}
}
[HttpDelete("~/api/settings/currencies/{id}")]
public ObjectResult Update([AsGuid] string id)
{
var exec = _currencyService.Remove(UserId, id.AsGuid());
switch (exec.Status)
{
case GeneralExecStatus.success:
return OkResponse(_mapper.Map<CurrencyViewModel>(exec.Result!));
case GeneralExecStatus.not_found:
case GeneralExecStatus.failure:
return ProblemBadResponse("Currency not found.");
default:
throw new NotSupportedException(exec.Status.ToString());
}
}
[HttpPost("~/api/settings/currencies/{id}/rate")]
public ObjectResult Add(string id, CurrencyRateModel currencyRate)
{