using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using MS.Models.ViewModel;
using MS.Services;
using MS.Services.PosTrxService;
using MS.WebCore.Core;
using System.Threading.Tasks;

namespace MS.WebApi.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class RoleController : ControllerBase
    {
        private readonly IRoleService _roleService;
        private readonly IPosTrxService _PosTrxService;

        public RoleController(IRoleService roleService, IPosTrxService posTrxService)
        {
            _roleService = roleService;
            _PosTrxService = posTrxService;
        }
        [Route("GetPos")]
        [EnableCors("AllowSpecificOrigin")]
        [HttpPost]
        public async Task<ExecuteResult> GetPos()
        {
            return null;
        }
        [HttpPost]
        public async Task<ExecuteResult> Post(RoleViewModel viewModel)
        {
            return await _roleService.Create(viewModel);
        }

        [HttpPut]
        public async Task<ExecuteResult> Put(RoleViewModel viewModel)
        {
            return await _roleService.Update(viewModel);
        }

        [HttpDelete]
        public async Task<ExecuteResult> Delete(long id)
        {
            return await _roleService.Delete(new RoleViewModel { Id = id });
        }
    }
}