using EnotaryoPH.Data;
using EnotaryoPH.Web.Pages.Shared.Components.TakeSelfieImage;
using Exadel.Compreface.Clients.CompreFaceClient;
using Microsoft.AspNetCore.Mvc;

namespace EnotaryoPH.Web.Pages.Participant.Registration.Steps
{
    public class TakeSelfieModel : BaseTakeSelfiePageModel
    {
        public TakeSelfieModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService, ICompreFaceClient compreFaceClient, IConfiguration configuration)
            : base(notaryoDBContext, currentUserService, compreFaceClient, configuration)
        {
        }

        public void OnGet()
        {
        }

        public async Task<IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return Page();
            }
            var isMatchSuccess = await PostAsync();
            if (isMatchSuccess)
            {
                return Redirect($"/Participant/VideoCall/Waiting/{Transaction_UID}");
            }
            ModelState.AddModelError("", "Face Verification Failed");

            return Page();
        }

        [BindProperty]
        public TakeSelfieImageModel TakeSelfieImage { get; set; }
    }
}