using Microsoft.AspNetCore.Authorization;

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MTWorkHR.Application.Filters;
using MTWorkHR.Application.Identity;
using MTWorkHR.Application.Models;
using MTWorkHR.Application.Services.Interfaces;
using MTWorkHR.Identity.Services;

namespace MTWorkHR.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    [AppAuthorize]
    public class MeetingController : ControllerBase
    {
        private readonly IMeetingService _MeetingService;
        public MeetingController(IMeetingService UserMeetingService)
        {
            this._MeetingService = UserMeetingService;
        }
        [HttpGet("GetAll")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Meeting")]
        public async Task<ActionResult<List<MeetingDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
        {
            return Ok(await _MeetingService.GetAll(pagingInput));
        }
        [HttpGet("Get")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Meeting")]
        public async Task<ActionResult<MeetingDto>> Get(long MeetingId)
        {
            return Ok(await _MeetingService.GetById(MeetingId));
        }


        [HttpPost("Create")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Meeting.Create")]
        public async Task<ActionResult<MeetingDto>> Create([FromBody] MeetingDto input)
        {
            return await _MeetingService.Create(input);
        }

        [HttpPost("Update")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Meeting.Update")]
        public async Task<ActionResult<MeetingDto>> Update([FromBody] MeetingDto input)
        {
            return await _MeetingService.Update(input);
        }

        [HttpDelete("Delete")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Meeting.Delete")]
        public async Task Delete([FromQuery]long id)
        {
            await _MeetingService.Delete(id);
        }



    }
}
