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

namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
{
    public class CheckListTemplateHeaderEditPageModel : PageModel
    {
        private readonly ILogger<IndexModel> _logger;
        private readonly ICheckListService _checkListService;

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


        public CheckListTemplateHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService)
        {
            _logger = logger;
            _checkListService = checkListService;
        }
        public async Task OnGet(int id)
        {
            CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id);
        }
        public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id)
        {
            CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id);
            return new JsonResult(new { data = CheckListTemplateHeaderDTO.CheckListTemplateRowDTO });
        }
    }
}
