From 503b59f300b6aaeb75c38d277e0860f38dab908c Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Sun, 15 Dec 2024 10:49:00 +0000 Subject: [PATCH] remove CommissionLocation; Age validation --- .../EnotaryoPH.Web/Pages/Register.cshtml | 20 +++++++--- .../EnotaryoPH.Web/Pages/Register.cshtml.cs | 40 +++++-------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml b/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml index 5578564..43c725a 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml @@ -17,13 +17,23 @@
@Html.ValidationMessageFor(x => x.Password)
-
+
+ + @Html.ValidationMessageFor(x => x.ConfirmPassword) -
+
-
-
+
+ + + @Html.ValidationMessageFor(x => x.PhoneNumber) +
+
+ + + @Html.ValidationMessageFor(x => x.BirthDate) +
@@ -44,12 +54,10 @@
-
-
diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml.cs b/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml.cs index eebf811..5f37033 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml.cs +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Register.cshtml.cs @@ -19,30 +19,7 @@ namespace EnotaryoPH.Web.Pages _passwordService = passwordService; } - public void OnGet() - { - RoleType = "Principal"; -#if DEBUG - RollNumber = "ROLL1234"; - IBPNumber = "IBP1234"; - MCLEComplianceNumber = "MCLE1234"; - MCLEDate = new DateTime(2023, 1, 15, 0, 0, 0, DateTimeKind.Utc); - PTRDate = new DateTime(2023, 1, 15, 0, 0, 0, DateTimeKind.Utc); - PTRLocation = "ptr location"; - PTRNumber = "PTR98723"; - CommissionExpiration = new DateTime(2023, 1, 15, 0, 0, 0, DateTimeKind.Utc); - CommissionLocation = "COMM LOC 8732"; - CommissionNumber = "COMM NO 8392"; - OfficeAddress = "123 Fictional Road, NY, Cubao"; - - PhoneNumber = "639151220001"; - BirthDate = new DateTime(1979, 9, 10, 0, 0, 0, DateTimeKind.Utc); - Password = "arst1234"; - ConfirmPassword = "arst1234"; - - -#endif - } + public void OnGet() => RoleType = "Principal"; public IActionResult OnPost() { @@ -58,6 +35,13 @@ namespace EnotaryoPH.Web.Pages return Page(); } + var today = DateTime.Now; + if (today.Year - BirthDate.Year < 18 || (today.Year - BirthDate.Year == 18 && BirthDate.Month < today.Month)) + { + ModelState.AddModelError(nameof(BirthDate), "You must be 18 or older"); + return Page(); + } + var newUser = new User { BirthDate = new DateTime(BirthDate.Ticks, DateTimeKind.Utc), @@ -74,7 +58,6 @@ namespace EnotaryoPH.Web.Pages { User = newUser, CommissionExpiration = new DateTime(CommissionExpiration.Value.Ticks, DateTimeKind.Utc), - CommissionLocation = CommissionLocation, CommissionNumber = CommissionNumber, IBPNumber = IBPNumber, MCLEComplianceNumber = MCLEComplianceNumber, @@ -101,10 +84,10 @@ namespace EnotaryoPH.Web.Pages public string Password { get; set; } [BindProperty] - [Compare(nameof(Password))] + [Compare(nameof(Password), ErrorMessage = "Passwords must match")] public string ConfirmPassword { get; set; } - [BindProperty] + [BindProperty, Required] public string PhoneNumber { get; set; } [BindProperty] @@ -140,9 +123,6 @@ namespace EnotaryoPH.Web.Pages [BindProperty] public DateTime? CommissionExpiration { get; set; } - [BindProperty] - public string? CommissionLocation { get; set; } - [BindProperty] public string? OfficeAddress { get; set; }