This commit is contained in:
2023-06-17 14:25:51 +03:00
parent 7ae5d3bc81
commit 5e0965cfd1
4 changed files with 25 additions and 9 deletions
+14 -2
View File
@@ -4,8 +4,10 @@ using Core.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Models.Account;
using MyOffice.Data.Models.Accounts;
using MyOffice.Web.Models.AccountMotion;
using Services.Account;
using Services.Account.Domain;
[Authorize]
[ApiController]
@@ -43,8 +45,18 @@ public class AccountController : BaseApiController
[HttpPost("~/api/accounts/{id}/motions")]
public object AccountsMotionsPost(string id, AccountMotionRequest accountMotion)
{
var list = _accountService.GetByCategoryDetailed(UserId, category!.AsGuid());
var exec = _accountService.AccountMotionAdd(UserId, id.AsGuid(), accountMotion.FromModel());
switch (exec.Status)
{
case AccountMotionAddResult.account_not_found:
return ProblemBadRequest("Account failed.");
case AccountMotionAddResult.failure:
return ProblemBadRequest("Adding motion failed.");
case AccountMotionAddResult.success:
return exec.Result!;
return list.Select(x => x.ToModel());
default:
throw new NotSupportedException(exec.Status.ToString());
}
}
}