diff --git a/EnotaryoPH/EnotaryoPH.Data/Constants/SignatoryStatus.cs b/EnotaryoPH/EnotaryoPH.Data/Constants/SignatoryStatus.cs index 00a60bb..bc228b3 100644 --- a/EnotaryoPH/EnotaryoPH.Data/Constants/SignatoryStatus.cs +++ b/EnotaryoPH/EnotaryoPH.Data/Constants/SignatoryStatus.cs @@ -4,6 +4,7 @@ { New = 0, EmailSent = 1, - Registered = 2 + Registered = 2, + FaceMatch = 3 } } \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Data/Entities/Transactionsignatory.cs b/EnotaryoPH/EnotaryoPH.Data/Entities/Transactionsignatory.cs index 11678d1..a3a96e7 100644 --- a/EnotaryoPH/EnotaryoPH.Data/Entities/Transactionsignatory.cs +++ b/EnotaryoPH/EnotaryoPH.Data/Entities/Transactionsignatory.cs @@ -5,34 +5,37 @@ namespace EnotaryoPH.Data.Entities [Table("TransactionSignatories")] public class TransactionSignatory { - [Column("TransactionSignatoryID")] - public int TransactionSignatoryID { get; set; } - - [Column("TransactionID")] - public int TransactionID { get; set; } - - [Column("UserID")] - public int? UserID { get; set; } - [Column("CreatedOn")] public DateTime? CreatedOn { get; set; } - [Column("Status")] - public string Status { get; set; } - [Column("Email")] public string Email { get; set; } - [Column("Type")] - public string Type { get; set; } + [Column("InvitationCode")] + public string InvitationCode { get; set; } + + [Column("Status")] + public string Status { get; set; } + + [ForeignKey("TransactionID")] + public Transaction Transaction { get; set; } + + [Column("TransactionID")] + public int TransactionID { get; set; } [Column("TransactionSignatory_UID")] public Guid? TransactionSignatory_UID { get; set; } - [Column("InvitationCode")] - public string InvitationCode { get; set; } + [Column("TransactionSignatoryID")] + public int TransactionSignatoryID { get; set; } - [ForeignKey("TransactionID")] - public Transaction Transaction { get; set; } + [Column("Type")] + public string Type { get; set; } + + [ForeignKey("UserID")] + public User? User { get; set; } + + [Column("UserID")] + public int? UserID { get; set; } } } \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Common/Extensions/StringExtensions.cs b/EnotaryoPH/EnotaryoPH.Web/Common/Extensions/StringExtensions.cs index 344c0fd..45ec8ef 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Common/Extensions/StringExtensions.cs +++ b/EnotaryoPH/EnotaryoPH.Web/Common/Extensions/StringExtensions.cs @@ -10,7 +10,7 @@ public static string NullIfWhiteSpace(this string s) => string.IsNullOrWhiteSpace(s) ? null : s; - public static Guid ToGuidFromString(this string s) + public static Guid ToGuidFromBase64(this string s) { if (s.Length != 22) { diff --git a/EnotaryoPH/EnotaryoPH.Web/Common/Jobs/SignatoryInvitationInvocable.cs b/EnotaryoPH/EnotaryoPH.Web/Common/Jobs/SignatoryInvitationInvocable.cs index 0c8a272..d3011bb 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Common/Jobs/SignatoryInvitationInvocable.cs +++ b/EnotaryoPH/EnotaryoPH.Web/Common/Jobs/SignatoryInvitationInvocable.cs @@ -40,6 +40,10 @@ namespace EnotaryoPH.Web.Common.Jobs MainPrincipalName = name, SignatoryType = signatory.Type })); + + signatory.Status = nameof(SignatoryStatus.EmailSent); + _notaryoDBContext.TransactionSignatories.Update(signatory); + _notaryoDBContext.SaveChanges(); } } } \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml index 087fec1..d50a1b5 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml @@ -2,3 +2,61 @@ @model EnotaryoPH.Web.Pages.Participant.Registration.IndexModel @{ } + +@section Head { + +} + + +
+

Principal/Witness Registration

+
+
+
+ +
+
+ +
+
+
+
+
+ @Html.ValidationMessage("Birthdate") +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml.cs b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml.cs index bc454c9..d9f40ea 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml.cs +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Index.cshtml.cs @@ -1,3 +1,6 @@ +using System.ComponentModel.DataAnnotations; +using EnotaryoPH.Data; +using EnotaryoPH.Data.Entities; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -5,9 +8,113 @@ namespace EnotaryoPH.Web.Pages.Participant.Registration { public class IndexModel : PageModel { - public IActionResult OnGet() => Page(); + private readonly NotaryoDBContext _notaryoDBContext; + + public IndexModel(NotaryoDBContext notaryoDBContext) => _notaryoDBContext = notaryoDBContext; + + public IActionResult OnGet() + { + if (string.IsNullOrEmpty(InvitationCode)) + { + return NotFound(); + } + + var invitationCodeGuid = InvitationCode.ToGuidFromBase64(); + var signatory = _notaryoDBContext.TransactionSignatories.FirstOrDefault(e => e.InvitationCode == invitationCodeGuid.ToString() && e.Status == nameof(SignatoryStatus.New)); + if (signatory == null) + { + return NotFound(); + } + + var existingUser = _notaryoDBContext.Users.FirstOrDefault(e => e.Email.ToLower() == signatory.Email.ToLower()); + if (existingUser != null) + { + signatory.Status = nameof(SignatoryStatus.Registered); + signatory.UserID = existingUser.UserID; + _notaryoDBContext.Update(signatory); + _notaryoDBContext.SaveChanges(); + return Redirect("Steps/UploadIdentification"); + } + + TransactionSignatory_UID = signatory.TransactionSignatory_UID.GetValueOrDefault(); + + return Page(); + } + + public IActionResult OnPost() + { + if (!ModelState.IsValid) + { + return Page(); + } + + if (TransactionSignatory_UID == Guid.Empty) + { + ModelState.AddModelError(nameof(TransactionSignatory_UID), "TransactionSignatory_UID is missing."); + return Page(); + } + + var signatory = _notaryoDBContext.TransactionSignatories.FirstOrDefault(e => e.TransactionSignatory_UID == TransactionSignatory_UID && e.Status == nameof(SignatoryStatus.New)); + if (signatory == null) + { + return BadRequest(); + } + + var newUser = new User + { + BirthDate = new DateTime(Year.Value, Month.Value, Day.Value, 0, 0, 0, DateTimeKind.Utc), + CreatedOn = DateTime.UtcNow, + Email = signatory.Email, + Firstname = Firstname, + Lastname = Lastname, + Middlename = Middlename, + PhoneNumber = PhoneNumber, + Prefix = Prefix, + Role = signatory.Type, + Suffix = Suffix, + User_UID = Guid.CreateVersion7(DateTime.UtcNow), + PasswordHash = "secret" + }; + _notaryoDBContext.Add(newUser); + signatory.User = newUser; + signatory.Status = nameof(SignatoryStatus.Registered); + _notaryoDBContext.Update(signatory); + _notaryoDBContext.SaveChanges(); + + return Redirect("Steps/UploadIdentification"); + } [BindProperty(SupportsGet = true)] public string InvitationCode { get; set; } + + [BindProperty] + public Guid TransactionSignatory_UID { get; set; } + + [BindProperty, Required] + public int? Year { get; set; } + + [BindProperty, Required] + public int? Month { get; set; } + + [BindProperty, Required] + public int? Day { get; set; } + + [BindProperty, Required] + public string PhoneNumber { get; set; } + + [BindProperty, Required] + public string Firstname { get; set; } + + [BindProperty, Required] + public string Lastname { get; set; } + + [BindProperty] + public string? Middlename { get; set; } + + [BindProperty] + public string? Suffix { get; set; } + + [BindProperty] + public string? Prefix { get; set; } } } \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Steps/UploadIdentification.cshtml b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Steps/UploadIdentification.cshtml new file mode 100644 index 0000000..ad8ea2d --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Steps/UploadIdentification.cshtml @@ -0,0 +1,106 @@ +@page +@model EnotaryoPH.Web.Pages.Participant.Registration.Steps.UploadIdentificationModel + +
+
+

Registration Steps

+ +
+
+
+
+
+
+
+
+
+
+
+
+ +
+

passport-2024-12-07__final.jpg

+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Existing Identification Documents

+
+ + + + + + + + + + + + + + + + + + + + +
Identification Document TypeUploaded On
Driver's License2024-11-31
Passport2024-12-17
+
+
+
+
+
+
NEXT +
+
+
\ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Steps/UploadIdentification.cshtml.cs b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Steps/UploadIdentification.cshtml.cs new file mode 100644 index 0000000..b780ade --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Participant/Registration/Steps/UploadIdentification.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace EnotaryoPH.Web.Pages.Participant.Registration.Steps +{ + public class UploadIdentificationModel : PageModel + { + public void OnGet() + { + } + } +}