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 AttendanceController : ControllerBase
    {
        private readonly IAttendanceService _AttendanceService;
        public AttendanceController(IAttendanceService UserAttendanceService)
        {
            this._AttendanceService = UserAttendanceService;
        }
        [HttpGet("GetAll")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Attendance")]
        public async Task<ActionResult<List<AttendanceDto>>> GetAll([FromQuery] AttendancePagingInputDto pagingInput)
        {
            return Ok(await _AttendanceService.GetAll(pagingInput));
        }
        [HttpGet("Get")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "Attendance")]
        public async Task<ActionResult<AttendanceDto>> Get(long AttendanceId)
        {
            return Ok(await _AttendanceService.GetById(AttendanceId));
        }


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

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

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



    }
}
