using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UserManagement.Data.Dto;
using UserManagement.MediatR.Commands;
using UserManagement.MediatR.Queries;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using UserManagement.Api.Helpers;
namespace UserManagement.API.Controllers
{
///
/// Page Action
///
[Route("api")]
[ApiController]
[Authorize]
public class PageActionController : BaseController
{
public IMediator _mediator { get; set; }
///
/// Page Action
///
///
public PageActionController(IMediator mediator)
{
_mediator = mediator;
}
///
/// Get All Page Actions
///
///
[HttpGet("PageActions")]
[Produces("application/json", "application/xml", Type = typeof(List))]
[ClaimCheck("page_action_edit", "role_add", "role_edit", "user_permission_edit")]
public async Task GetPageActions()
{
var getAllPageActionQuery = new GetAllPageActionQuery { };
var result = await _mediator.Send(getAllPageActionQuery);
return Ok(result);
}
///
/// Add Page Action
///
///
///
[HttpPost("PageAction")]
[Produces("application/json", "application/xml", Type = typeof(PageActionDto))]
[ClaimCheck("page_action_edit")]
public async Task AddPageAction(AddPageActionCommand addPageActionCommand)
{
var result = await _mediator.Send(addPageActionCommand);
return ReturnFormattedResponse(result);
}
///
/// Delete Page Action By Id
///
///
///
[HttpDelete("PageAction/{Id}")]
[ClaimCheck("page_action_edit")]
public async Task DeletePageAction(Guid Id)
{
var deletePageActionCommand = new DeletePageActionCommand { Id = Id };
var result = await _mediator.Send(deletePageActionCommand);
return ReturnFormattedResponse(result);
}
}
}