using EnotaryoPH.Data;
using Microsoft.AspNetCore.Mvc;

namespace EnotaryoPH.Web.Pages.Participant.Registration.Steps
{
    public class UploadIdentificationModel : BaseIdentificationDocumentPageModel
    {
        private readonly ICurrentUserService _currentUserService;

        public UploadIdentificationModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService)
            : base(notaryoDBContext) => _currentUserService = currentUserService;

        public void OnGet()
        {
        }

        public async Task<IActionResult> OnPostAsync()
        {
            if (UploadNewIdentification)
            {
                if (!ModelState.IsValid)
                {
                    return Page();
                }

                CreateIdentificationDocument(_currentUserService.GetUser_UID());
            }

            return Redirect($"../TakeSelfie/{Transaction_UID}");
        }

        [BindProperty(SupportsGet = true)]
        public Guid Transaction_UID { get; set; }
    }
}