fix Principal Dashboard
This commit is contained in:
		
							parent
							
								
									2457a64c9c
								
							
						
					
					
						commit
						2041e12029
					
				
							
								
								
									
										11
									
								
								EnotaryoPH/EnotaryoPH.Data/Constants/TransactionStatus.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								EnotaryoPH/EnotaryoPH.Data/Constants/TransactionStatus.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| namespace EnotaryoPH.Data.Constants | ||||
| { | ||||
|     public enum TransactionStatus | ||||
|     { | ||||
|         New = 0, | ||||
|         SelfiePassed = 1, | ||||
|         DocumentUploaded = 2, | ||||
|         Submitted = 3, | ||||
|         Completed = 100 | ||||
|     } | ||||
| } | ||||
| @ -12,8 +12,8 @@ namespace EnotaryoPH.Web.Pages | ||||
| { | ||||
|     public class LoginModel : PageModel | ||||
|     { | ||||
|         private readonly IPasswordService _passwordService; | ||||
|         private readonly NotaryoDBContext _notaryoDBContext; | ||||
|         private readonly IPasswordService _passwordService; | ||||
| 
 | ||||
|         public LoginModel(IPasswordService passwordService, NotaryoDBContext notaryoDBContext) | ||||
|         { | ||||
| @ -51,10 +51,10 @@ namespace EnotaryoPH.Web.Pages | ||||
| 
 | ||||
|             var claims = new List<Claim> | ||||
|                 { | ||||
|                     new("User_UID", user.User_UID.ToString()), | ||||
|                     new(ClaimTypes.NameIdentifier, user.User_UID.ToString()), | ||||
|                     new(ClaimTypes.Name, user.Email), | ||||
|                     new(ClaimTypes.Email, user.Email), | ||||
|                     new(ClaimTypes.Role, user.Role) | ||||
|                     new(ClaimTypes.Role, user.Role!) | ||||
|                 }; | ||||
|             var claimsIdentity = new ClaimsIdentity( | ||||
|                 claims, CookieAuthenticationDefaults.AuthenticationScheme); | ||||
| @ -65,7 +65,7 @@ namespace EnotaryoPH.Web.Pages | ||||
|                 new ClaimsPrincipal(claimsIdentity), | ||||
|                 authProperties); | ||||
| 
 | ||||
|             return RedirectToPage("/Principal/Dashboard"); | ||||
|             return RedirectToPage("/Principal/Dashboard/Dashboard"); | ||||
|         } | ||||
| 
 | ||||
|         [Required] | ||||
|  | ||||
| @ -1,12 +0,0 @@ | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.AspNetCore.Mvc.RazorPages; | ||||
| 
 | ||||
| namespace EnotaryoPH.Web.Pages.Principal | ||||
| { | ||||
|     public class DashboardModel : PageModel | ||||
|     { | ||||
|         public void OnGet() | ||||
|         { | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -1,5 +1,5 @@ | ||||
| @page | ||||
| @model EnotaryoPH.Web.Pages.Principal.DashboardModel | ||||
| @model EnotaryoPH.Web.Pages.Principal.Dashboard.DashboardModel | ||||
| @{ | ||||
| } | ||||
| 
 | ||||
| @ -12,14 +12,14 @@ | ||||
|         <div class="row"> | ||||
|             <div class="col-2 col-sm-1 col-md-3 g-0"> | ||||
|                 <div class="sidemenu"> | ||||
|                     <div class="align-items-center sidemenu__menuitem"><a class="d-flex flex-grow-1 justify-content-center align-items-center justify-content-md-start p-1 text-decoration-none" href="/principal/notaryowizard1_identification.html"><i class="fas fa-magic fs-4 text-dark sidemenu__menuitem__icon" style="padding: 5px;"></i><span class="d-none d-md-inline-block ms-1 sidemenu__menuitem__text">Create New</span></a></div> | ||||
|                     <div class="align-items-center sidemenu__menuitem"><a class="d-flex flex-grow-1 justify-content-center align-items-center justify-content-md-start p-1 text-decoration-none" href="#"><i class="far fa-check-circle fs-4 text-success sidemenu__menuitem__icon" style="padding: 5px;"></i><span class="d-none d-md-inline-block ms-1 sidemenu__menuitem__text">Completed</span></a></div> | ||||
|                     <div class="align-items-center sidemenu__menuitem"><a class="d-flex flex-grow-1 justify-content-center align-items-center justify-content-md-start p-1 text-decoration-none" href="#"><i class="fas fa-magic fs-4 text-dark sidemenu__menuitem__icon" style="padding: 5px;"></i><span class="d-none d-md-inline-block ms-1 sidemenu__menuitem__text">Create New</span></a></div> | ||||
|                     <div class="align-items-center sidemenu__menuitem"><a class="d-flex flex-grow-1 justify-content-center align-items-center justify-content-md-start p-1 text-decoration-none" href="#completed-docs"><i class="far fa-check-circle fs-4 text-success sidemenu__menuitem__icon" style="padding: 5px;"></i><span class="d-none d-md-inline-block ms-1 sidemenu__menuitem__text">Completed</span></a></div> | ||||
|                     <div class="align-items-center sidemenu__menuitem"><a class="d-flex flex-grow-1 justify-content-center align-items-center justify-content-md-start p-1 text-decoration-none" href="#incomplete-docs"><i class="far fa-clock fs-4 text-warning sidemenu__menuitem__icon" style="padding: 5px;"></i><span class="d-none d-md-inline-block ms-1 sidemenu__menuitem__text">Incomplete</span></a></div> | ||||
|                     <div class="align-items-center sidemenu__menuitem"><a class="d-flex flex-grow-1 justify-content-center align-items-center justify-content-md-start p-1 text-decoration-none" href="#identification-docs"><i class="far fa-address-card fs-4 text-dark sidemenu__menuitem__icon" style="padding: 5px;"></i><span class="d-none d-md-inline-block ms-1 sidemenu__menuitem__text">Identification Docs</span></a></div> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="col g-0 mx-2"> | ||||
|                 <div class="row g-0 mb-5"> | ||||
|                 <div id="completed-docs" class="row g-0 mb-5"> | ||||
|                     <div class="col"> | ||||
|                         <h3>Completed Documents</h3> | ||||
|                         <div class="table-responsive"> | ||||
| @ -32,16 +32,25 @@ | ||||
|                                     </tr> | ||||
|                                 </thead> | ||||
|                                 <tbody> | ||||
|                                     <tr> | ||||
|                                         <td>Deed of Absolute Sale</td> | ||||
|                                         <td>2024-11-01</td> | ||||
|                                         <td><a href="#">Download</a></td> | ||||
|                                     </tr> | ||||
|                                     <tr> | ||||
|                                         <td>Certification<br />against non-forum shopping</td> | ||||
|                                         <td>2024-01-25</td> | ||||
|                                         <td><a href="#">Download</a></td> | ||||
|                                     </tr> | ||||
|                                     @if (Model.CompletedDocuments.Count > 0) | ||||
|                                     { | ||||
|                                         @foreach (var item in Model.CompletedDocuments) | ||||
|                                         { | ||||
|                                             <tr> | ||||
|                                                 <td>@item.Type</td> | ||||
|                                                 <td>@item.Date.ToShortDateString()</td> | ||||
|                                                 <td><a href="@item.Link">View</a></td> | ||||
|                                             </tr> | ||||
|                                         } | ||||
|                                     } | ||||
|                                     else | ||||
|                                     { | ||||
|                                         <tr> | ||||
|                                             <td colspan="3"> | ||||
|                                                 No records to display. | ||||
|                                             </td> | ||||
|                                         </tr> | ||||
|                                     } | ||||
|                                 </tbody> | ||||
|                             </table> | ||||
|                         </div> | ||||
| @ -60,16 +69,23 @@ | ||||
|                                     </tr> | ||||
|                                 </thead> | ||||
|                                 <tbody> | ||||
|                                     <tr> | ||||
|                                         <td>Deed of Absolute Sale</td> | ||||
|                                         <td>Submitted</td> | ||||
|                                         <td><a href="#">View</a></td> | ||||
|                                     </tr> | ||||
|                                     <tr> | ||||
|                                         <td>Certification<br />against non-forum shopping</td> | ||||
|                                         <td>Assigned</td> | ||||
|                                         <td><a href="#">View</a></td> | ||||
|                                     </tr> | ||||
|                                     @if(Model.CompletedDocuments.Count > 0){ | ||||
|                                         @foreach (var item in Model.CompletedDocuments) | ||||
|                                         { | ||||
|                                             <tr> | ||||
|                                                 <td>@item.Type</td> | ||||
|                                                 <td>@item.Status</td> | ||||
|                                                 <td><a href="@item.Link">View</a></td> | ||||
|                                             </tr> | ||||
|                                         } | ||||
|                                     } | ||||
|                                     else { | ||||
|                                         <tr> | ||||
|                                             <td colspan="3"> | ||||
|                                                 No records to display. | ||||
|                                             </td> | ||||
|                                         </tr> | ||||
|                                     } | ||||
|                                 </tbody> | ||||
|                             </table> | ||||
|                         </div> | ||||
| @ -88,19 +104,34 @@ | ||||
|                                     </tr> | ||||
|                                 </thead> | ||||
|                                 <tbody> | ||||
|                                     <tr> | ||||
|                                         <td>Driver's License</td> | ||||
|                                         <td>2024-11-01</td> | ||||
|                                         <td><a href="#">View</a></td> | ||||
|                                     </tr> | ||||
|                                     <tr> | ||||
|                                         <td>Passport</td> | ||||
|                                         <td>2024-01-25</td> | ||||
|                                         <td><a href="#">View</a></td> | ||||
|                                     </tr> | ||||
|                                     @if (Model.CompletedDocuments.Count > 0) | ||||
|                                     { | ||||
|                                         @foreach (var item in Model.CompletedDocuments) | ||||
|                                         { | ||||
|                                             <tr> | ||||
|                                                 <td>@item.Type</td> | ||||
|                                                 <td>@item.Date.ToShortDateString()</td> | ||||
|                                                 <td><a href="@item.Link">View</a></td> | ||||
|                                             </tr> | ||||
|                                         } | ||||
|                                     } | ||||
|                                     else | ||||
|                                     { | ||||
|                                         <tr> | ||||
|                                             <td colspan="3"> | ||||
|                                                 No records to display. | ||||
|                                             </td> | ||||
|                                         </tr> | ||||
|                                     } | ||||
|                                 </tbody> | ||||
|                             </table> | ||||
|                         </div> | ||||
|                         <div> | ||||
|                             <button class="btn btn-primary btn-sm" type="button"> | ||||
|                                 <i class="fas fa-upload me-1"></i> | ||||
|                                 Upload | ||||
|                             </button> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
| @ -0,0 +1,61 @@ | ||||
| using EnotaryoPH.Data; | ||||
| using EnotaryoPH.Data.Constants; | ||||
| using EnotaryoPH.Web.Common.Services; | ||||
| using Microsoft.AspNetCore.Mvc.RazorPages; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| 
 | ||||
| namespace EnotaryoPH.Web.Pages.Principal.Dashboard | ||||
| { | ||||
|     public class DashboardModel : PageModel | ||||
|     { | ||||
|         private readonly NotaryoDBContext _notaryoDBContext; | ||||
|         private readonly ICurrentUserService _currentUserService; | ||||
| 
 | ||||
|         public DashboardModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService) | ||||
|         { | ||||
|             _notaryoDBContext = notaryoDBContext; | ||||
|             _currentUserService = currentUserService; | ||||
|         } | ||||
| 
 | ||||
|         public void OnGet() | ||||
|         { | ||||
|             var user = _notaryoDBContext.Users.FirstOrDefault(u => u.User_UID == _currentUserService.GetUser_UID()); | ||||
| 
 | ||||
|             _notaryoDBContext.Transactions.Include(t => t.TransactionDocument); | ||||
|             var userTransactions = _notaryoDBContext.Transactions.Where(e => e.PrincipalID == user.UserID).ToList(); | ||||
|             CompletedDocuments = userTransactions | ||||
|                 .Where(ut => ut.Status == nameof(TransactionStatus.Completed)) | ||||
|                 .Select(ut => new DashboardItem | ||||
|                 { | ||||
|                     Date = ut.TransactionDate, | ||||
|                     Status = ut.Status, | ||||
|                     Type = ut.TransactionDocument.DocumentType, | ||||
|                     Link = "#" | ||||
|                 }) | ||||
|                 .ToList(); | ||||
|             IncompleteDocuments = userTransactions | ||||
|                 .Where(ut => ut.Status != nameof(TransactionStatus.Completed)) | ||||
|                 .Select(ut => new DashboardItem | ||||
|                 { | ||||
|                     Date = ut.TransactionDate, | ||||
|                     Status = ut.Status, | ||||
|                     Type = ut.TransactionDocument.DocumentType, | ||||
|                     Link = "#" | ||||
|                 }) | ||||
|                 .ToList(); | ||||
|             IdentificationDocuments = _notaryoDBContext.IdentificationDocuments | ||||
|                 .Where(id => id.UserID == user.UserID) | ||||
|                 .Select(id => new DashboardItem | ||||
|                 { | ||||
|                     Date = id.UploadedOn, | ||||
|                     Type = id.Type, | ||||
|                     Link = "#" | ||||
|                 }) | ||||
|                 .ToList(); | ||||
|         } | ||||
| 
 | ||||
|         public List<DashboardItem> CompletedDocuments { get; set; } | ||||
|         public List<DashboardItem> IncompleteDocuments { get; set; } | ||||
|         public List<DashboardItem> IdentificationDocuments { get; set; } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| namespace EnotaryoPH.Web.Pages.Principal.Dashboard | ||||
| { | ||||
|     public class DashboardItem | ||||
|     { | ||||
|         public DateTime Date { get; set; } | ||||
|         public string Link { get; set; } | ||||
|         public string Status { get; set; } | ||||
|         public string Type { get; set; } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user