add Notary Transaction status button
This commit is contained in:
		
							parent
							
								
									dee870c7bb
								
							
						
					
					
						commit
						45f6a7ee6c
					
				| @ -0,0 +1,60 @@ | ||||
| @page "{Transaction_UID}" | ||||
| @model EnotaryoPH.Web.Pages.Notary.TransactionStatus.IndexModel | ||||
| @{ | ||||
| } | ||||
| 
 | ||||
| @section Head { | ||||
|     <link href="\lib\fontawesome-free-6.7.1-web\css\all.min.css" rel="stylesheet" /> | ||||
| } | ||||
| 
 | ||||
| <section class="my-5"> | ||||
|     <div class="container"> | ||||
|         <div class="row"> | ||||
|             <div class="col-xl-8"> | ||||
|                 <h1>@Model.Title</h1> | ||||
| 
 | ||||
|                 <div class="row"> | ||||
|                     <div class="col"> | ||||
|                         <p>Started on @Model.StartedOn.ToShortDateString() @Model.StartedOn.ToShortTimeString().</p> | ||||
|                         <p>@Model.StatusDescription</p> | ||||
|                         @if (Model.Signatories.Count > 0) { | ||||
|                             <div class="table-responsive"> | ||||
|                                 <table class="table"> | ||||
|                                     <thead> | ||||
|                                         <tr> | ||||
|                                             <th>Email</th> | ||||
|                                             <th>Type</th> | ||||
|                                             <th>Status</th> | ||||
|                                         </tr> | ||||
|                                     </thead> | ||||
|                                     <tbody> | ||||
|                                         @foreach(var row in Model.Signatories) | ||||
|                                         { | ||||
|                                             <tr> | ||||
|                                                 <td>@row.Email</td> | ||||
|                                                 <td>@row.Type</td> | ||||
|                                                 <td>@row.Status</td> | ||||
|                                             </tr> | ||||
|                                         } | ||||
|                                     </tbody> | ||||
|                                 </table> | ||||
|                             </div> | ||||
|                         } | ||||
| 
 | ||||
|                     </div> | ||||
|                 </div> | ||||
| 
 | ||||
|                 <div class="mt-3 d-flex"> | ||||
|                     @if(Model.IsTaken) { | ||||
|                         <a class="btn btn-primary btn-lg" role="button" href="/"><i class="fas fa-home me-2"></i>BACK TO HOME </a> | ||||
|                     } | ||||
|                     else { | ||||
|                         <form method="post"> | ||||
|                             <input type="submit" class="btn btn-primary btn-lg" value="ACCEPT JOB" /> | ||||
|                         </form> | ||||
|                     } | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </section> | ||||
| @ -0,0 +1,110 @@ | ||||
| using EnotaryoPH.Data; | ||||
| using EnotaryoPH.Data.Entities; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.AspNetCore.Mvc.RazorPages; | ||||
| 
 | ||||
| namespace EnotaryoPH.Web.Pages.Notary.TransactionStatus | ||||
| { | ||||
|     public class IndexModel : PageModel | ||||
|     { | ||||
|         private const string STATUS_READY = "Ready"; | ||||
|         private readonly ICurrentUserService _currentUserService; | ||||
|         private readonly IConferenceSheduleService _conferenceSheduleService; | ||||
|         private readonly NotaryoDBContext _notaryoDBContext; | ||||
|         private Transaction? _transaction; | ||||
| 
 | ||||
|         public IndexModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService, IConferenceSheduleService conferenceSheduleService) | ||||
|         { | ||||
|             _notaryoDBContext = notaryoDBContext; | ||||
|             _currentUserService = currentUserService; | ||||
|             _conferenceSheduleService = conferenceSheduleService; | ||||
|         } | ||||
| 
 | ||||
|         public IActionResult OnGet() | ||||
|         { | ||||
|             _transaction = _notaryoDBContext | ||||
|                 .Transactions | ||||
|                 .AsNoTracking() | ||||
|                 .Include(t => t.TransactionSignatories) | ||||
|                 .Include(t => t.TransactionDocument) | ||||
|                 .Include(t => t.Principal) | ||||
|                 .FirstOrDefault(e => e.Transaction_UID == Transaction_UID); | ||||
| 
 | ||||
|             if (_transaction == null) | ||||
|             { | ||||
|                 return NotFound(); | ||||
|             } | ||||
| 
 | ||||
|             Title = _transaction.TransactionDocument.DocumentType; | ||||
|             StartedOn = _transaction.CreatedOn.GetValueOrDefault(); | ||||
|             StatusDescription = "Not all signatories have signed up to enotaryo and completed the onboarding process. This transaction cannot proceed until this has been resolved."; | ||||
| 
 | ||||
|             var signatories = _transaction.TransactionSignatories.ConvertAll(s => new SignatoryViewModel | ||||
|             { | ||||
|                 Email = s.Email, | ||||
|                 Type = s.Type, | ||||
|                 Status = ChangeStatusLabel(s.Status) | ||||
|             }); | ||||
|             signatories.Add(new SignatoryViewModel | ||||
|             { | ||||
|                 Email = _transaction.Principal.Email, | ||||
|                 Status = STATUS_READY, | ||||
|                 Type = nameof(UserType.Principal) | ||||
|             }); | ||||
| 
 | ||||
|             Signatories = signatories.OrderBy(sig => sig.Type).ThenBy(sig => sig.Email).ToList(); | ||||
| 
 | ||||
|             var isReady = Signatories.TrueForAll(sig => sig.Status == STATUS_READY); | ||||
|             if (isReady) | ||||
|             { | ||||
|                 StatusDescription = _transaction.Status == nameof(TransactionState.Accepted) | ||||
|                     ? "This transaction is already assigned to a lawyer and is being processed." | ||||
|                     : "All signatories have signed up to enotaryo and completed the onboarding process. This transaction is ready to be processed."; | ||||
|             } | ||||
| 
 | ||||
|             return Page(); | ||||
|         } | ||||
| 
 | ||||
|         public async Task<IActionResult> OnPostAsync() | ||||
|         { | ||||
|             _transaction = _notaryoDBContext | ||||
|                 .Transactions | ||||
|                 .Include(t => t.TransactionSignatories) | ||||
|                 .FirstOrDefault(e => e.Transaction_UID == Transaction_UID); | ||||
|             if (_transaction == null) | ||||
|             { | ||||
|                 return NotFound(); | ||||
|             } | ||||
| 
 | ||||
|             var user = _notaryoDBContext.Users.Single(u => u.User_UID == _currentUserService.GetUser_UID()); | ||||
|             var lawyer = _notaryoDBContext.Lawyers.Single(l => l.UserID == user.UserID); | ||||
|             _transaction.Status = nameof(TransactionState.Accepted); | ||||
|             _transaction.LawyerID = lawyer.LawyerID; | ||||
|             _notaryoDBContext.Update(_transaction); | ||||
| 
 | ||||
|             var schedule_UID = await _conferenceSheduleService.GetOrCreateScheduleIDAsync(Transaction_UID); | ||||
|             if (schedule_UID != Guid.Empty) | ||||
|             { | ||||
|                 return _transaction.TransactionSignatories.TrueForAll(sig => sig.Status == nameof(SignatoryStatus.FaceMatch)) | ||||
|                     ? Redirect($"/Participant/VideoCall/Room/{Transaction_UID}") | ||||
|                     : Redirect($"/Participant/VideoCall/Waiting/{Transaction_UID}"); | ||||
|             } | ||||
| 
 | ||||
|             return Redirect("/Notary/Dashboard"); | ||||
|         } | ||||
| 
 | ||||
|         private string ChangeStatusLabel(string status) => status switch { nameof(SignatoryStatus.FaceMatch) => STATUS_READY, _ => status }; | ||||
| 
 | ||||
|         public bool IsTaken => string.Equals(_transaction?.Status, nameof(TransactionState.Accepted), StringComparison.OrdinalIgnoreCase); | ||||
|         public List<SignatoryViewModel> Signatories { get; private set; } = []; | ||||
| 
 | ||||
|         public DateTime StartedOn { get; private set; } | ||||
| 
 | ||||
|         public string StatusDescription { get; private set; } | ||||
| 
 | ||||
|         public string Title { get; private set; } | ||||
| 
 | ||||
|         [BindProperty(SupportsGet = true)] | ||||
|         public Guid Transaction_UID { get; set; } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,9 @@ | ||||
| namespace EnotaryoPH.Web.Pages.Notary.TransactionStatus | ||||
| { | ||||
|     public class SignatoryViewModel | ||||
|     { | ||||
|         public string Email { get; set; } | ||||
|         public string Status { get; set; } | ||||
|         public string Type { get; set; } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user