using BPMService.Models;
using MassTransit;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using WK_KLI_LAPS_Service.App_Data;
using WK_KLI_LAPS_Service.Controllers.WorkArea;

namespace WK_KLI_LAPS_Service.Controllers.Dashboard
{
    [Route("api/[controller]")]
    [ApiController]
    public class AuthorDashboardApiController : ControllerBase
    {
        AuthorDashboardService oAuthorDashboardService = new AuthorDashboardService();
        CommonRepository oCommonRepository = new CommonRepository();
        WorkAreaService oWorkAreaService = new WorkAreaService();

        private readonly IRequestClient<ISimpleRequest, ISimpleResponse> _requestClient;

        public AuthorDashboardApiController(IRequestClient<ISimpleRequest, ISimpleResponse> requestClient)
        {
            _requestClient = requestClient;
        }

        [Authorize]
        [HttpPost("getAuthorDashboardData")]
        public IActionResult getAuthorDashboardData([FromBody] dashboardModel data)
        {
            data.searchtext = data.searchtext != "" ? "%" + data.searchtext + "%" : "%%";
            string inputstr = JsonConvert.SerializeObject(data);
            var _list = oAuthorDashboardService.getauthordashboarddata(inputstr);
            return Ok(_list);

        }
        [Authorize]
        [HttpPost("getAuthorDashboardrowcount")]
        public IActionResult getAuthorDashboardrowcount([FromBody] dashboardModel data)
        {
            data.searchtext = data.searchtext != "" ? "%" + data.searchtext + "%" : "%%";
            string inputstr = JsonConvert.SerializeObject(data);
            var _list = oAuthorDashboardService.getAuthorDashboardrowcount(inputstr);
            return Ok(_list);

        }
    }
}