Files
Backend-Api/ServiceHost/Areas/Admin/Controllers/ProgramManager/UserController.cs

67 lines
1.9 KiB
C#
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
}
}