create transaction during selfie success
This commit is contained in:
		
							parent
							
								
									256839489a
								
							
						
					
					
						commit
						400b819794
					
				| @ -40,12 +40,26 @@ namespace EnotaryoPH.Web.Pages | ||||
|                     signatory.Status = nameof(SignatoryStatus.FaceMatch); | ||||
|                     _notaryoDBContext.Update(signatory); | ||||
|                 } | ||||
|                 else if (!_user.Role.IsInList(nameof(UserType.Principal), nameof(UserType.SuperUser), nameof(UserType.Administrator))) | ||||
|                 else if (!CurrentUser.Role.IsInList(nameof(UserType.Principal), nameof(UserType.SuperUser), nameof(UserType.Administrator))) | ||||
|                 { | ||||
|                     return false; | ||||
|                 } | ||||
| 
 | ||||
|                 if (CurrentTransaction.TransactionID == 0) | ||||
|                 { | ||||
|                     var newTransaction = new Transaction | ||||
|                     { | ||||
|                         Transaction_UID = Guid.CreateVersion7(DateTime.UtcNow), | ||||
|                         CreatedOn = DateTime.UtcNow, | ||||
|                         TransactionDate = DateTime.UtcNow, | ||||
|                         Status = nameof(TransactionState.New), | ||||
|                         PrincipalID = CurrentUser.UserID | ||||
|                     }; | ||||
|                     _notaryoDBContext.Add(CurrentTransaction); | ||||
|                 } | ||||
| 
 | ||||
|                 var selfieEntity = CreateOrUpdateSelfie(selfieImage); | ||||
|                 selfieEntity.Transaction = CurrentTransaction; | ||||
|                 if (_notaryoDBContext.Entry(selfieEntity).State == EntityState.Detached) | ||||
|                 { | ||||
|                     _notaryoDBContext.Add(selfieEntity); | ||||
| @ -69,7 +83,7 @@ namespace EnotaryoPH.Web.Pages | ||||
|                     CreatedOn = DateTime.UtcNow, | ||||
|                     TransactionSelfie_UID = Guid.CreateVersion7(DateTime.UtcNow), | ||||
|                     UserID = CurrentUser.UserID, | ||||
|                     TransactionID = TransactionID | ||||
|                     TransactionID = CurrentTransaction.TransactionID, | ||||
|                 }; | ||||
|                 TransactionSelfie_UID = selfieEntity.TransactionSelfie_UID.Value; | ||||
|             } | ||||
| @ -115,28 +129,17 @@ namespace EnotaryoPH.Web.Pages | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public Guid TransactionSelfie_UID { get; set; } | ||||
| 
 | ||||
|         private User CurrentUser | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (_user == null) | ||||
|                 { | ||||
|                     _user = _notaryoDBContext.Users.AsNoTracking().First(x => x.User_UID == _currentUserService.GetUser_UID()); | ||||
|                 } | ||||
|                 return _user ?? new(); | ||||
|             } | ||||
|         } | ||||
|         protected User CurrentUser => _user ??= _notaryoDBContext.Users.AsNoTracking().First(x => x.User_UID == _currentUserService.GetUser_UID()); | ||||
| 
 | ||||
|         private int TransactionID | ||||
|         { | ||||
|             get | ||||
|         protected Transaction CurrentTransaction => _transactionEntity | ||||
|             ??= _notaryoDBContext.Transactions.AsNoTracking().FirstOrDefault(x => x.Transaction_UID == Transaction_UID) | ||||
|             ?? new Transaction | ||||
|             { | ||||
|                 if (_transactionEntity == null) | ||||
|                 { | ||||
|                     _transactionEntity = _notaryoDBContext.Transactions.AsNoTracking().First(x => x.Transaction_UID == Transaction_UID); | ||||
|                 } | ||||
|                 return _transactionEntity?.TransactionID ?? 0; | ||||
|             } | ||||
|         } | ||||
|                 Transaction_UID = Guid.CreateVersion7(DateTime.UtcNow), | ||||
|                 CreatedOn = DateTime.UtcNow, | ||||
|                 TransactionDate = DateTime.UtcNow, | ||||
|                 Status = nameof(TransactionState.New), | ||||
|                 PrincipalID = CurrentUser.UserID | ||||
|             }; | ||||
|     } | ||||
| } | ||||
| @ -24,7 +24,7 @@ namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps | ||||
|             var isMatchSuccess = await PostAsync(); | ||||
|             if (isMatchSuccess) | ||||
|             { | ||||
|                 return Redirect($"/Principal/NotaryoSteps/UploadDocument/{Transaction_UID}"); | ||||
|                 return Redirect($"/Principal/NotaryoSteps/UploadDocument/{CurrentTransaction.Transaction_UID}"); | ||||
|             } | ||||
|             ModelState.AddModelError("", "Face Verification Failed"); | ||||
| 
 | ||||
|  | ||||
| @ -86,7 +86,6 @@ | ||||
| 
 | ||||
|     const data = control_canvas.toDataURL('image/jpg'); | ||||
|     control_photo.setAttribute('src', data); | ||||
|     debugger; | ||||
|     control_selfieBase64Image.value = data; | ||||
| 
 | ||||
|     _showPhoto(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user