67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using GozareshgirProgramManager.Application._Common.Models;
|
||
using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser;
|
||
using GozareshgirProgramManager.Application.Modules.Users.Commands.EditUser;
|
||
using GozareshgirProgramManager.Application.Modules.Users.Queries.GetSingleUser;
|
||
using GozareshgirProgramManager.Application.Modules.Users.Queries.GetUsers;
|
||
using GozareshgirProgramManager.Application.Modules.Users.Queries.GetUserSelectList;
|
||
using MediatR;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using ServiceHost.BaseControllers;
|
||
|
||
namespace ServiceHost.Areas.Admin.Controllers.ProgramManager;
|
||
|
||
public class UserController : ProgramManagerBaseController
|
||
{
|
||
private readonly IMediator _mediator;
|
||
|
||
|
||
public UserController(IMediator mediator)
|
||
{
|
||
_mediator = mediator;
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<ActionResult<OperationResult<GetUsersResponse>>> Get([FromQuery] GetUsersQuery query)
|
||
{
|
||
var res = await _mediator.Send(query);
|
||
return res;
|
||
}
|
||
|
||
|
||
[HttpGet("{accountId}")]
|
||
public async Task<ActionResult<OperationResult<GetSingleUserResponse>>> GetUserByAccountId(string accountId)
|
||
{
|
||
var query = new GetSingleUserQuery(accountId);
|
||
var res = await _mediator.Send(query);
|
||
|
||
return res;
|
||
}
|
||
|
||
[HttpGet("GetUserSelectList")]
|
||
public async Task<ActionResult<OperationResult<GetUserSelectListResponse>>> GetUserSelectList()
|
||
{
|
||
var query = new GetUserSelectListQuery();
|
||
var res = await _mediator.Send(query);
|
||
|
||
return res;
|
||
}
|
||
|
||
|
||
[HttpPost("create")]
|
||
public async Task<ActionResult<OperationResult>> Create([FromBody] CreateUserCommand command)
|
||
{
|
||
var res = await _mediator.Send(command);
|
||
return res;
|
||
}
|
||
|
||
|
||
[HttpPost("edit")]
|
||
public async Task<ActionResult<OperationResult>> Edit([FromBody] EditUserCommand command)
|
||
{
|
||
var res = await _mediator.Send(command);
|
||
return res;
|
||
}
|
||
|
||
|
||
} |