46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using GozareshgirProgramManager.Application._Common.Models;
|
||
using GozareshgirProgramManager.Application.Modules.Roles.Commands.CreateRole;
|
||
using GozareshgirProgramManager.Application.Modules.Roles.Commands.EditRole;
|
||
using GozareshgirProgramManager.Application.Modules.Roles.Queries.GetRoles;
|
||
using MediatR;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using ServiceHost.BaseControllers;
|
||
|
||
namespace ServiceHost.Areas.Admin.Controllers.ProgramManager;
|
||
|
||
public class RoleController : ProgramManagerBaseController
|
||
{
|
||
private readonly IMediator _mediator;
|
||
|
||
public RoleController(IMediator mediator)
|
||
{
|
||
_mediator = mediator;
|
||
}
|
||
|
||
|
||
[HttpGet]
|
||
public async Task<ActionResult<OperationResult<GetRolesResponse>>> Get([FromQuery] GetRolesQuery query)
|
||
{
|
||
var res = await _mediator.Send(query);
|
||
return res;
|
||
}
|
||
|
||
|
||
[HttpPost]
|
||
public async Task<ActionResult<OperationResult>> Create([FromBody] CreateRoleCommand command)
|
||
{
|
||
var res = await _mediator.Send(command);
|
||
return res;
|
||
}
|
||
|
||
|
||
|
||
[HttpPost("edit")]
|
||
public async Task<ActionResult<OperationResult>> Edit([FromBody] EditRoleCommand command)
|
||
{
|
||
var res = await _mediator.Send(command);
|
||
return res;
|
||
}
|
||
|
||
|
||
} |