This commit is contained in:
2023-07-23 20:27:23 +03:00
parent d0cdaa85b6
commit 96eca795ab
62 changed files with 2934 additions and 847 deletions
@@ -1,5 +1,6 @@
namespace MyOffice.Web.Controllers;
using AutoMapper;
using Core;
using Core.Extensions;
using Microsoft.AspNetCore.Authorization;
@@ -18,28 +19,29 @@ using Services.Item;
public class AccountController : BaseApiController
{
private readonly ILogger<AccountController> _logger;
private readonly IMapper _mapper;
private readonly AccountService _accountService;
private readonly ItemService _itemService;
public AccountController(
ILogger<AccountController> logger,
IMapper mapper,
AccountService accountService,
ItemService itemService
)
{
_logger = logger;
_mapper = mapper;
_accountService = accountService;
_itemService = itemService;
}
[HttpGet("~/api/accounts")]
public object AccountsGet(string category)
public List<AccountDetailedViewModel> AccountsGet(string category)
{
var list = _accountService.GetByCategoryDetailed(UserId, category!.AsGuid());
return list
.OrderBy(x => x.Account.Name)
.Select(x => x.ToModel());
return _mapper.Map<List<AccountDetailedViewModel>>(list.OrderBy(x => x.Account.Name).ToList());
}
[HttpGet("~/api/accounts/{id}")]
@@ -54,7 +56,8 @@ public class AccountController : BaseApiController
return ProblemBadRequest("Account not found.");
case GeneralExecStatus.success:
return exec.Result!.ToModel();
return _mapper.Map<AccountDetailedViewModel>(exec.Result);
//return exec.Result!.ToModel();
default:
throw new NotSupportedException(exec.Status.ToString());