sort waiting participants by SortOrder
This commit is contained in:
parent
10be070fae
commit
7d82832e42
@ -9,57 +9,65 @@ namespace EnotaryoPH.Web.Pages.Participant.VideoCall
|
|||||||
{
|
{
|
||||||
private readonly NotaryoDBContext _dbContext;
|
private readonly NotaryoDBContext _dbContext;
|
||||||
private readonly ICurrentUserService _currentUserService;
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
private readonly IConferenceSheduleService _conferenceSheduleService;
|
||||||
private Transaction _transactionEntity;
|
private Transaction _transactionEntity;
|
||||||
|
|
||||||
public WaitingModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService)
|
public WaitingModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService, IConferenceSheduleService conferenceSheduleService)
|
||||||
{
|
{
|
||||||
_dbContext = notaryoDBContext;
|
_dbContext = notaryoDBContext;
|
||||||
_currentUserService = currentUserService;
|
_currentUserService = currentUserService;
|
||||||
|
_conferenceSheduleService = conferenceSheduleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult OnGet()
|
public async Task<IActionResult> OnGetAsync()
|
||||||
{
|
{
|
||||||
_transactionEntity = _dbContext.Transactions
|
_transactionEntity = _dbContext.Transactions
|
||||||
.Include(t => t.TransactionSignatories)
|
.Include(t => t.TransactionSignatories)
|
||||||
.ThenInclude(ts => ts.User)
|
.ThenInclude(ts => ts.User)
|
||||||
.Include(t => t.Lawyer)
|
.Include(t => t.Lawyer)
|
||||||
|
.ThenInclude(l => l.User)
|
||||||
.Include(t => t.Principal)
|
.Include(t => t.Principal)
|
||||||
.FirstOrDefault(t => t.Transaction_UID == Transaction_UID);
|
.FirstOrDefault(t => t.Transaction_UID == Transaction_UID);
|
||||||
if (_transactionEntity == null)
|
if (_transactionEntity == null || _transactionEntity.Status.IsInList(TransactionState.Completed))
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var schedule_UID = await _conferenceSheduleService.GetOrCreateScheduleIDAsync(Transaction_UID);
|
||||||
|
if (schedule_UID != Guid.Empty)
|
||||||
|
{
|
||||||
|
return Redirect($"/Participant/VideoCall/Room/{Transaction_UID}");
|
||||||
|
}
|
||||||
|
|
||||||
var participants = _transactionEntity.TransactionSignatories
|
var participants = _transactionEntity.TransactionSignatories
|
||||||
.Select(t => new WaitingForParticipantViewModel
|
.ConvertAll(t => new WaitingForParticipantViewModel
|
||||||
{
|
{
|
||||||
Email = t.Email,
|
Email = t.Email,
|
||||||
Status = ConvertToWaitingStatus(t.Status),
|
Status = ConvertToWaitingStatus(t.Status),
|
||||||
Type = t.Email == _currentUserService.GetEmail() ? "(You)" : t.Type,
|
Type = string.Equals(t.Email, _currentUserService.GetEmail(), StringComparison.OrdinalIgnoreCase) ? "(You)" : t.Type,
|
||||||
UID = t.TransactionSignatory_UID.GetValueOrDefault()
|
UID = t.TransactionSignatory_UID.GetValueOrDefault(),
|
||||||
})
|
SortOrder = 3
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (_transactionEntity.LawyerID > 0)
|
|
||||||
{
|
|
||||||
participants.Add(new WaitingForParticipantViewModel
|
|
||||||
{
|
|
||||||
Email = _transactionEntity.Lawyer.User.Email,
|
|
||||||
Status = "Waiting",
|
|
||||||
Type = nameof(UserType.Notary),
|
|
||||||
UID = Guid.Empty
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
participants.Add(new WaitingForParticipantViewModel
|
||||||
|
{
|
||||||
|
Email = _transactionEntity.Lawyer?.User?.Email ?? "notarypublic@enotaryo.ph",
|
||||||
|
Status = "Waiting",
|
||||||
|
Type = nameof(UserType.Notary),
|
||||||
|
UID = _transactionEntity.Lawyer?.User?.User_UID ?? Guid.Empty,
|
||||||
|
SortOrder = 1
|
||||||
|
});
|
||||||
|
|
||||||
participants.Add(new WaitingForParticipantViewModel
|
participants.Add(new WaitingForParticipantViewModel
|
||||||
{
|
{
|
||||||
Email = _transactionEntity.Principal.Email,
|
Email = _transactionEntity.Principal.Email,
|
||||||
Status = "Ready",
|
Status = "Ready",
|
||||||
Type = nameof(UserType.Principal),
|
Type = nameof(UserType.Principal),
|
||||||
UID = Guid.Empty
|
UID = _transactionEntity.Principal?.User_UID ?? Guid.Empty,
|
||||||
|
SortOrder = 2
|
||||||
});
|
});
|
||||||
|
|
||||||
Participants = participants.OrderBy(p => p.Type).ToList();
|
Participants = participants.OrderBy(p => p.SortOrder).ThenBy(p => p.Email).ToList();
|
||||||
|
|
||||||
return Page();
|
return Page();
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public Guid UID { get; set; }
|
public Guid UID { get; set; }
|
||||||
|
public int SortOrder { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user