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 OrderAllocationController : ControllerBase
    {
        private readonly IOrderAllocationService _OrderAllocationService;
        public OrderAllocationController(IOrderAllocationService UserOrderAllocationService)
        {
            this._OrderAllocationService = UserOrderAllocationService;
        }
        [HttpGet("GetAll")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "OrderAllocation")]
        public async Task<ActionResult<List<OrderAllocationDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
        {
            return Ok(await _OrderAllocationService.GetAll(pagingInput));
        }
        [HttpGet("Get")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [AppAuthorize(Permissions = "OrderAllocation")]
        public async Task<ActionResult<OrderAllocationDto>> Get(long OrderAllocationId)
        {
            return Ok(await _OrderAllocationService.GetById(OrderAllocationId));
        }


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

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

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



    }
}
