new IdentificationDocumentModelMapper
This commit is contained in:
parent
295e561562
commit
e4c217f955
@ -1,4 +1,5 @@
|
||||
using EnotaryoPH.Data.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace EnotaryoPH.Web.Common.Models
|
||||
@ -19,16 +20,36 @@ namespace EnotaryoPH.Web.Common.Models
|
||||
Filename = document.Filename;
|
||||
ImageBase64Url = File.ToBase64StringUrl();
|
||||
IdentificationType = document.Type;
|
||||
IdentificationDocument_UID = document.IdentificationDocument_UID.GetValueOrDefault();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public DateTime? DateIssued { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public IFormFile File { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public IFormFile? File { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string Filename { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string IdentificationType { get; set; }
|
||||
|
||||
public List<SelectListItem>? IdentificationTypes { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string IdNumber { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string? ImageBase64Url { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string PlaceIssued { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public Guid IdentificationDocument_UID { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using EnotaryoPH.Data.Entities;
|
||||
|
||||
namespace EnotaryoPH.Web.Common.Models
|
||||
{
|
||||
internal static class IdentificationDocumentModelMapper
|
||||
{
|
||||
internal static IdentificationDocument ToEntity(this IdentificationDocumentModel model, int userID)
|
||||
{
|
||||
var entity = new IdentificationDocument
|
||||
{
|
||||
UploadedOn = DateTime.UtcNow,
|
||||
UserID = userID
|
||||
};
|
||||
|
||||
return model.ToEntity(entity);
|
||||
}
|
||||
|
||||
internal static IdentificationDocument ToEntity(this IdentificationDocumentModel model, IdentificationDocument entity)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(nameof(model.File));
|
||||
|
||||
entity.ExpirationDate = model.ExpirationDate.ToUTC();
|
||||
entity.DateIssued = model.DateIssued.ToUTC();
|
||||
entity.PlaceIssued = model.PlaceIssued;
|
||||
entity.IdNumber = model.IdNumber;
|
||||
entity.Type = model.IdentificationType;
|
||||
|
||||
var file = model.File;
|
||||
entity.Filename = file.FileName;
|
||||
var stream = new MemoryStream((int)file.Length);
|
||||
file.CopyTo(stream);
|
||||
entity.File = stream.ToArray();
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user