public void Start() { var builder = new ContainerBuilder(); _core = AppCoreBuilder.Create(builder) .AddModule <NCoreFileStorageModule>() .AddModule(new NHibernatePostgreModule() { AssemblyMapper = Assembly.GetExecutingAssembly(), ConnectionStringKey = "ncore-test-base", AfterConfigure = e => { FileStorageCore.Configure(e); SecurityCore.Configure(e); } }) .AddModule(new NCoreSecurityNHibernateModule()) .Configure(c => { c.RegisterType <TestService>().As <ITestService>(); c.RegisterType <TestRepository>().As <ITestRepository>(); }) .Build(); var service = _core.Resolve <ITestService>(); service.AddTestRecord(); }
public async Task <IActionResult> UploadDocumentSignature(IFormFile file) { if (file == null) { return(Ok()); } if (file.Length == 0) { return(BadRequest("File size is zero.")); } var storage = new FileStorageCore(dc, CurrentUserId); var storageId = await storage.Save(file); dc.DbTran(() => { var doc = new UserDocument { UserId = CurrentUserId, Tag = "DocumentSignature", FileStorageId = storageId }; dc.Table <UserDocument>().Add(doc); }); return(Ok()); }
public async Task <IActionResult> UploadIdentificationVerification(VmIdentificationVerification model) { var storage = new FileStorageCore(dc, CurrentUserId); var frontSidePhoto = await storage.Save(model.FrontSidePhoto); var backSidePhoto = await storage.Save(model.BackSidePhoto); dc.DbTran(() => { var identification = dc.Table <UserIdentification>().FirstOrDefault(x => x.UserId == CurrentUserId); if (identification == null) { dc.Table <UserIdentification>().Add(new UserIdentification { UserId = CurrentUserId, DocumentTypeId = model.DocumentTypeId, DocumentNumber = model.DocumentNumber, IssueDate = model.IssueDate, ExpiryDate = model.ExpiryDate }); } else { identification.DocumentTypeId = model.DocumentTypeId; identification.DocumentNumber = model.DocumentNumber; identification.IssueDate = model.IssueDate; identification.ExpiryDate = model.ExpiryDate; } if (!String.IsNullOrEmpty(frontSidePhoto)) { var doc = new UserDocument { UserId = CurrentUserId, Tag = "FrontSidePhotoId", FileStorageId = frontSidePhoto }; dc.Table <UserDocument>().Add(doc); } if (!String.IsNullOrEmpty(backSidePhoto)) { var doc = new UserDocument { UserId = CurrentUserId, Tag = "BackSidePhotoId", FileStorageId = backSidePhoto }; dc.Table <UserDocument>().Add(doc); } }); return(Ok()); }
public IActionResult GetDocumentSignature() { var file = (from us in dc.Table <UserDocument>() join fs in dc.Table <FileStorage>() on us.FileStorageId equals fs.Id where us.UserId == CurrentUserId && us.Tag == "DocumentSignature" orderby us.UpdatedTime descending select new { Name = fs.OriginalFileName, fs.Size, fs.ConvertedFileName }).FirstOrDefault(); var storage = new FileStorageCore(dc, CurrentUserId); return(Ok(new { file?.Name, file?.Size, Path = (file?.ConvertedFileName == null) ? "" : storage.GetFilePath(file.ConvertedFileName) })); }
public Object GetIdentificationVerification() { var identification = dc.Table <UserIdentification>().FirstOrDefault(x => x.UserId == CurrentUserId); var frontSidePhoto = (from us in dc.Table <UserDocument>() join fs in dc.Table <FileStorage>() on us.FileStorageId equals fs.Id where us.UserId == CurrentUserId && us.Tag == "FrontSidePhotoId" orderby us.UpdatedTime descending select new { Name = fs.OriginalFileName, fs.Size, fs.ConvertedFileName }).FirstOrDefault(); var backSidePhoto = (from us in dc.Table <UserDocument>() join fs in dc.Table <FileStorage>() on us.FileStorageId equals fs.Id where us.UserId == CurrentUserId && us.Tag == "BackSidePhotoId" orderby us.UpdatedTime descending select new { Name = fs.OriginalFileName, fs.Size, fs.ConvertedFileName }).FirstOrDefault(); var storage = new FileStorageCore(dc, CurrentUserId); return(new { DocumentNumber = identification?.DocumentNumber, DocumentTypeId = identification?.DocumentTypeId, ExpiryDate = identification?.ExpiryDate, IssueDate = identification?.IssueDate, FrontSidePhoto = new { frontSidePhoto?.Name, frontSidePhoto?.Size, Path = (frontSidePhoto?.ConvertedFileName == null) ? "" : storage.GetFilePath(frontSidePhoto.ConvertedFileName) }, BackSidePhoto = new { backSidePhoto?.Name, backSidePhoto?.Size, Path = (backSidePhoto?.ConvertedFileName == null) ? "" : storage.GetFilePath(backSidePhoto.ConvertedFileName) } }); }