Files
myoffice/MyOffice.Web/Controllers/AccountController.cs
T
2023-06-17 14:16:09 +03:00

50 lines
1.2 KiB
C#

namespace MyOffice.Web.Controllers;
using Core.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Models.Account;
using MyOffice.Web.Models.AccountMotion;
using Services.Account;
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class AccountController : BaseApiController
{
private readonly ILogger<AccountController> _logger;
private readonly AccountService _accountService;
public AccountController(
ILogger<AccountController> logger,
AccountService accountService
)
{
_logger = logger;
_accountService = accountService;
}
[HttpGet("~/api/accounts")]
public object AccountsGet(string category)
{
var list = _accountService.GetByCategoryDetailed(UserId, category!.AsGuid());
return list.Select(x => x.ToModel());
}
[HttpGet("~/api/accounts/{id}/motions")]
public object AccountsMotionsGet(string category)
{
var list = _accountService.GetByCategoryDetailed(UserId, category!.AsGuid());
return list.Select(x => x.ToModel());
}
[HttpPost("~/api/accounts/{id}/motions")]
public object AccountsMotionsPost(string id, AccountMotionRequest accountMotion)
{
var list = _accountService.GetByCategoryDetailed(UserId, category!.AsGuid());
return list.Select(x => x.ToModel());
}
}