using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using WorkFlowCheck.Web.Services.Interfaces;

namespace WorkFlowCheck.Web.Pages.BaseStock.Equipments
{
    [Authorize]
    public class EquipmentsPageModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;
        private readonly IBaseStockService _baseStockService;
        public EquipmentsPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
        {
            _logger = logger;
            _baseStockService = baseStockService;
        }
        public async Task OnGet()
        {
        }
        public async Task<JsonResult> OnGetLoadEquipments()
        {
            var results = await _baseStockService.GetAllEquipments();
            return new JsonResult(new { data = results });
        }
        public async Task<JsonResult> OnGetDeleteEquipment(int id)
        {
            var isSuccess = await _baseStockService.DeleteEquipment(id);
            return new JsonResult(new { result = isSuccess });
        }
    }
}
