diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Principal/NotaryoSteps/UploadIdentification.cshtml.cs b/EnotaryoPH/EnotaryoPH.Web/Pages/Principal/NotaryoSteps/UploadIdentification.cshtml.cs index 95a8039..dca75c3 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Principal/NotaryoSteps/UploadIdentification.cshtml.cs +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Principal/NotaryoSteps/UploadIdentification.cshtml.cs @@ -1,39 +1,19 @@ using EnotaryoPH.Data; using EnotaryoPH.Web.Common.Models; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.Rendering; namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps { - public class UploadIdentificationModel : PageModel + public class UploadIdentificationModel : BaseIdentificationDocumentPageModel { private readonly ICurrentUserService _currentUserService; - private readonly NotaryoDBContext _notaryoDBContext; public UploadIdentificationModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService) + : base(notaryoDBContext) => _currentUserService = currentUserService; + + public void OnGetAsync() { - _notaryoDBContext = notaryoDBContext; - _currentUserService = currentUserService; - } - - public async Task OnGetAsync() - { - var user = _notaryoDBContext.Users.AsNoTracking().FirstOrDefault(u => u.User_UID == _currentUserService.GetUser_UID()); - if (user == null) - { - return BadRequest(); - } - ExistingIdentificationDocuments = GetIdentityDocumentsByUserID(user.UserID); - - NewIdentificationDocument = new IdentificationDocumentModel - { - IdentificationTypes = GetIdentificationDocumentTypes() - }; - - UploadNewIdentification = true; - - return Page(); } public async Task OnPostAsync() @@ -48,6 +28,8 @@ namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps }; return Page(); } + + CreateIdentificationDocument(_currentUserService.GetUser_UID()); } return RedirectToPage("/Principal/NotaryoSteps/TakeSelfie"); @@ -64,24 +46,10 @@ namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps }); } - private List GetIdentityDocumentsByUserID(int userID) => - _notaryoDBContext.IdentificationDocuments.AsNoTracking() - .Where(d => d.UserID == userID) - .Select(d => new IdentificationDocumentModel(d)).ToList(); - public int ExistingIdentificationDocumentCount => ExistingIdentificationDocuments.Count; public List ExistingIdentificationDocuments { get; set; } = []; - [BindProperty(SupportsGet = true)] - public Guid IdentificationDocument_UID { get; set; } - - [BindProperty] - public IdentificationDocumentModel NewIdentificationDocument { get; set; } - - [BindProperty] - public bool UploadNewIdentification { get; set; } - public Guid Transaction_UID { get; private set; } } } \ No newline at end of file