using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces;

namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
{
    public class CheckListHeaderEditPageModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;
        private readonly ICheckListService _checkListService;

        [BindProperty]
        public CheckListHeaderDTO CheckListHeaderDTO { get; set; }


        public CheckListHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService)
        {
            _logger = logger;
            _checkListService = checkListService;
        }
        public async Task OnGet(int id)
        {
            CheckListHeaderDTO = await _checkListService.GetCheckListHeader(id);
        }
        public async Task<JsonResult> OnGetLoadCheckListRows(int id)
        {
            CheckListHeaderDTO = await _checkListService.GetCheckListHeader(id);
            return new JsonResult(new { data = CheckListHeaderDTO.CheckListRowDTO });
        }
    }
}
