restore upload document
This commit is contained in:
parent
400b819794
commit
d676bbd073
@ -24,12 +24,83 @@
|
|||||||
})
|
})
|
||||||
<div class="tab-content mt-3"></div>
|
<div class="tab-content mt-3"></div>
|
||||||
</div>
|
</div>
|
||||||
<form class="mt-4" id="UploadIdentificationForm" method="post" enctype="multipart/form-data">
|
<form class="mt-5" enctype="multipart/form-data" method="post" id="UploadDocumentForm">
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Document</label>
|
||||||
|
<input class="form-control" type="file" asp-for="DocumentFile" required />
|
||||||
|
@Html.ValidationMessageFor(x => x.DocumentFile)
|
||||||
|
</div>
|
||||||
|
|
||||||
@await Component.InvokeAsync("UploadOrChooseIdentificationDocument", Model.Transaction_UID)
|
</div>
|
||||||
<div class="d-flex mt-3">
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Document Type</label>
|
||||||
|
<select class="form-select" asp-for="DocumentType" asp-items="Model.DocumentTypes" required>
|
||||||
|
<option value="">Please choose an option</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
@Html.ValidationMessageFor(x => x.DocumentType)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-12 col-lg-6 col-xxl-6">
|
||||||
|
<label class="form-label">More than one principal?</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">Email</span>
|
||||||
|
<input class="form-control" type="email" id="NewPrincipalEmail" />
|
||||||
|
<button class="btn btn-secondary" type="button" id="AddAdditionalPrincipalButton">ADD</button>
|
||||||
|
</div>
|
||||||
|
<div class="field-validation-error">
|
||||||
|
<span id="AdditionalPrincipalsValidation"></span>
|
||||||
|
</div>
|
||||||
|
<ul class="mt-2" id="AdditionalPrincipalsList">
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-lg-6 col-xxl-6">
|
||||||
|
<label class="form-label">More than one witness?</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">Email</span>
|
||||||
|
<input class="form-control" type="email" id="NewWitnessEmail" />
|
||||||
|
<button class="btn btn-secondary" type="button" id="AddWitnessButton">ADD</button>
|
||||||
|
</div>
|
||||||
|
<div class="field-validation-error">
|
||||||
|
<span id="WitnessesValidation"></span>
|
||||||
|
</div>
|
||||||
|
<ul class="mt-2" id="WitnessesList">
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<fieldset>
|
||||||
|
<label class="form-label">Would you like to record the video conference?</label>
|
||||||
|
<div class="d-flex">
|
||||||
|
<div class="form-check me-3"><input id="formCheck-2" class="form-check-input" type="radio" name="IsRecorded" checked /><label class="form-check-label" for="formCheck-2">Yes, record the session</label></div>
|
||||||
|
<div class="form-check"><input id="formCheck-3" class="form-check-input" type="radio" name="IsRecorded" /><label class="form-check-label" for="formCheck-3">No, do not record the session</label></div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" asp-for="IsConfirmed" />
|
||||||
|
<label class="form-check-label" asp-for="IsConfirmed">I confirm and attest under oath that I freely and voluntarily executed the document; that I read and understood the same; and that the contents of the document are true and correct.</label>
|
||||||
|
</div>
|
||||||
|
@Html.ValidationMessageFor(x => x.IsConfirmed)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" asp-for="CurrentUserEmail" />
|
||||||
|
<input type="hidden" asp-for="ParticipantsJson" />
|
||||||
|
<div class="d-flex">
|
||||||
<div class="flex-grow-1"></div>
|
<div class="flex-grow-1"></div>
|
||||||
<button class="btn btn-primary btn-lg wizard__nextbutton" type="submit">NEXT<i class="fas fa-chevron-right ms-2"></i></button>
|
<button type="submit" class="btn btn-primary btn-lg" id="NextButton">
|
||||||
|
<span>NEXT</span>
|
||||||
|
<i class="fas fa-chevron-right ms-2"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,66 +1,123 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Text.Json;
|
||||||
using Coravel.Queuing.Interfaces;
|
using Coravel.Queuing.Interfaces;
|
||||||
using EnotaryoPH.Data;
|
using EnotaryoPH.Data;
|
||||||
|
using EnotaryoPH.Data.Entities;
|
||||||
using EnotaryoPH.Web.Common.Jobs;
|
using EnotaryoPH.Web.Common.Jobs;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
|
||||||
namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps
|
namespace EnotaryoPH.Web.Pages.Principal.NotaryoSteps
|
||||||
{
|
{
|
||||||
public class UploadDocumentModel : BaseIdentificationDocumentPageModel
|
public class UploadDocumentModel : PageModel
|
||||||
{
|
{
|
||||||
private readonly ICurrentUserService _currentUserService;
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
private readonly NotaryoDBContext _notaryoDBContext;
|
||||||
private readonly IQueue _queue;
|
private readonly IQueue _queue;
|
||||||
|
|
||||||
public UploadDocumentModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService, IQueue queue)
|
public UploadDocumentModel(NotaryoDBContext notaryoDBContext, ICurrentUserService currentUserService, IQueue queue)
|
||||||
: base(notaryoDBContext)
|
|
||||||
{
|
{
|
||||||
|
_notaryoDBContext = notaryoDBContext;
|
||||||
_currentUserService = currentUserService;
|
_currentUserService = currentUserService;
|
||||||
_queue = queue;
|
_queue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGet()
|
public IActionResult OnGet(Guid transaction_UID)
|
||||||
{
|
{
|
||||||
|
var _transaction = _notaryoDBContext.Transactions
|
||||||
|
.Include(t => t.TransactionDocument)
|
||||||
|
.Include(t => t.TransactionSignatories)
|
||||||
|
.AsNoTracking().FirstOrDefault(e => e.Transaction_UID == transaction_UID);
|
||||||
|
DocumentTypes = GetDocumentTypes();
|
||||||
|
CurrentUserEmail = _currentUserService.GetEmail();
|
||||||
|
var signatories = _transaction.TransactionSignatories.Select(ts => new SignatoryViewModel
|
||||||
|
{
|
||||||
|
Email = ts.Email,
|
||||||
|
Type = ts.Type,
|
||||||
|
UID = ts.TransactionSignatory_UID.GetValueOrDefault()
|
||||||
|
}).ToList();
|
||||||
|
ParticipantsJson = JsonSerializer.Serialize(signatories);
|
||||||
|
|
||||||
|
return Page();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync()
|
public async Task<IActionResult> OnPostAsync()
|
||||||
{
|
{
|
||||||
if (UploadNewIdentification)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
DocumentTypes = GetDocumentTypes();
|
||||||
{
|
return Page();
|
||||||
return Page();
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateIdentificationDocument(_currentUserService.GetUser_UID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SendSignatoryInvitations();
|
if (!IsConfirmed)
|
||||||
|
{
|
||||||
|
ModelState.AddModelError(nameof(IsConfirmed), "You must tick this box to continue.");
|
||||||
|
DocumentTypes = GetDocumentTypes();
|
||||||
|
return Page();
|
||||||
|
}
|
||||||
|
|
||||||
return Redirect($"/Principal/NotaryoSteps/ChooseNotary/{Transaction_UID}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SendSignatoryInvitations()
|
|
||||||
{
|
|
||||||
var transaction = _notaryoDBContext.Transactions
|
var transaction = _notaryoDBContext.Transactions
|
||||||
.Include(e => e.TransactionSignatories)
|
.Include(t => t.TransactionSignatories)
|
||||||
.FirstOrDefault(e => e.Transaction_UID == Transaction_UID);
|
.Include(t => t.TransactionDocument)
|
||||||
|
.FirstOrDefault(t => t.Transaction_UID == Transaction_UID);
|
||||||
|
if (transaction == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Status = nameof(TransactionState.DocumentUploaded);
|
||||||
|
transaction.IsRecorded = IsVideoConferenceRecorded;
|
||||||
|
|
||||||
|
if (transaction.TransactionDocument == null)
|
||||||
|
{
|
||||||
|
transaction.TransactionDocument = new TransactionDocument
|
||||||
|
{
|
||||||
|
CreatedOn = DateTime.UtcNow,
|
||||||
|
Transaction = transaction,
|
||||||
|
TransactionDocument_UID = Guid.CreateVersion7(DateTime.UtcNow),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var stream = new MemoryStream((int)DocumentFile.Length);
|
||||||
|
DocumentFile.CopyTo(stream);
|
||||||
|
transaction.TransactionDocument.File = stream.ToArray();
|
||||||
|
transaction.TransactionDocument.Filename = DocumentFile.FileName;
|
||||||
|
transaction.TransactionDocument.DocumentType = DocumentType;
|
||||||
|
transaction.TransactionDocument.UploadedOn = DateTime.UtcNow;
|
||||||
|
|
||||||
|
var participants = JsonSerializer.Deserialize<List<SignatoryViewModel>>(ParticipantsJson, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }) ?? [];
|
||||||
|
transaction.TransactionSignatories = participants.Select(p => new TransactionSignatory
|
||||||
|
{
|
||||||
|
CreatedOn = DateTime.UtcNow,
|
||||||
|
Email = p.Email,
|
||||||
|
Status = nameof(SignatoryStatus.New),
|
||||||
|
TransactionSignatory_UID = Guid.CreateVersion7(DateTime.UtcNow),
|
||||||
|
Type = p.Type,
|
||||||
|
InvitationCode = Guid.CreateVersion7(DateTime.UtcNow).ToString()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
_notaryoDBContext.Update(transaction);
|
||||||
|
_notaryoDBContext.SaveChanges();
|
||||||
|
|
||||||
foreach (var signatory in transaction.TransactionSignatories)
|
foreach (var signatory in transaction.TransactionSignatories)
|
||||||
{
|
{
|
||||||
_queue.QueueInvocableWithPayload<SignatoryInvitationInvocable, Guid>(signatory.TransactionSignatory_UID.GetValueOrDefault());
|
_queue.QueueInvocableWithPayload<SignatoryInvitationInvocable, Guid>(signatory.TransactionSignatory_UID.GetValueOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Redirect($"/Principal/NotaryoSteps/ChooseNotary/{Transaction_UID}");
|
||||||
}
|
}
|
||||||
|
|
||||||
//private List<SelectListItem> GetDocumentTypes()
|
private List<SelectListItem> GetDocumentTypes()
|
||||||
//{
|
{
|
||||||
// var lookupIdentificationTypes = _notaryoDBContext.LookupData.AsNoTracking().Include(e => e.LookupDataValues).FirstOrDefault(e => e.Name == "Document Types");
|
var lookupIdentificationTypes = _notaryoDBContext.LookupData.AsNoTracking().Include(e => e.LookupDataValues).FirstOrDefault(e => e.Name == "Document Types");
|
||||||
// return lookupIdentificationTypes.LookupDataValues
|
return lookupIdentificationTypes.LookupDataValues
|
||||||
// .ConvertAll(m => new SelectListItem
|
.ConvertAll(m => new SelectListItem
|
||||||
// {
|
{
|
||||||
// Text = m.Title.DefaultIfEmpty(m.Value),
|
Text = m.Title.DefaultIfEmpty(m.Value),
|
||||||
// Value = m.Value
|
Value = m.Value
|
||||||
// });
|
});
|
||||||
//}
|
}
|
||||||
|
|
||||||
public string CurrentUserEmail { get; private set; }
|
public string CurrentUserEmail { get; private set; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user