87 lines
2.8 KiB
C#

using System.ComponentModel.DataAnnotations;
using Coravel.Queuing.Interfaces;
using EnotaryoPH.Data;
using EnotaryoPH.Web.Common.Jobs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps
{
public class UploadDocumentModel : BaseIdentificationDocumentPageModel
{
private readonly ICurrentUserService _currentUserService;
private readonly IQueue _queue;
public UploadDocumentModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService, IQueue queue)
: base(notaryoDBContext)
{
_currentUserService = currentUserService;
_queue = queue;
}
public void OnGet()
{
}
public async Task<IActionResult> OnPostAsync()
{
if (UploadNewIdentification)
{
if (!ModelState.IsValid)
{
return Page();
}
CreateIdentificationDocument(_currentUserService.GetUser_UID());
}
SendSignatoryInvitations();
return Redirect($"/Principal/NotaryoSteps/ChooseNotary/{Transaction_UID}");
}
private void SendSignatoryInvitations()
{
var transaction = _notaryoDBContext.Transactions
.Include(e => e.TransactionSignatories)
.FirstOrDefault(e => e.Transaction_UID == Transaction_UID);
foreach (var signatory in transaction.TransactionSignatories)
{
_queue.QueueInvocableWithPayload<SignatoryInvitationInvocable, Guid>(signatory.TransactionSignatory_UID.GetValueOrDefault());
}
}
//private List<SelectListItem> GetDocumentTypes()
//{
// var lookupIdentificationTypes = _notaryoDBContext.LookupData.AsNoTracking().Include(e => e.LookupDataValues).FirstOrDefault(e => e.Name == "Document Types");
// return lookupIdentificationTypes.LookupDataValues
// .ConvertAll(m => new SelectListItem
// {
// Text = m.Title.DefaultIfEmpty(m.Value),
// Value = m.Value
// });
//}
public string CurrentUserEmail { get; private set; }
[BindProperty, Required]
public IFormFile DocumentFile { get; set; }
[BindProperty, Required]
public string DocumentType { get; set; }
public List<SelectListItem> DocumentTypes { get; set; }
[BindProperty]
public bool IsConfirmed { get; set; }
[BindProperty]
public bool IsVideoConferenceRecorded { get; set; }
[BindProperty]
public string ParticipantsJson { get; set; } = "[]";
[BindProperty(SupportsGet = true)]
public Guid Transaction_UID { get; set; }
}
}