private async Task Handle(DocumentUploaded documentUploaded) { if (documentUploaded.TranslationType != TranslationType.Google) { return; } var translationQueuedEvent = new TranslationQueued( aggregateId: Guid.NewGuid().ToSequentialGuid(), version: documentUploaded.Version + 1, correlationId: documentUploaded.AggregateId, causationId: documentUploaded.Id, userId: documentUploaded.UserId ); await _eventPublisher.PublishAsync(translationQueuedEvent); BackgroundJob.Enqueue(() => _translationWorker.StartAsync( new TranslationRequest( translationQueuedEvent.AggregateId, documentUploaded.AggregateId, translationQueuedEvent.CausationId.Value, translationQueuedEvent.Version, documentUploaded.UserId, documentUploaded.FileName, documentUploaded.TranslationSubject ) )); }
public void Handle(DocumentUploaded @event) { Id = @event.Subject; _state.Subject = @event.Subject; _state.TranslationType = @event.TranslationType; _state.TranslationOptionSubject = @event.TranslationSubject; _state.FileName = @event.FileName; _state.User = @event.User; Version = @event.Version; }
public async Task Handle(DocumentUploaded @event) { lock (_lockObj) { if (_handleTask == null) { _handleTask = Task.Run(async() => await _translation.HandleAsync(@event), _cts.Token); } } await _handleTask; }
private async Task HandleAsync(DocumentUploaded @event, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { _logger.LogInformation($"{nameof(DocumentProjectionManager)}.{nameof(HandleAsync)} was cancelled before execution"); cancellationToken.ThrowIfCancellationRequested(); } await Task.WhenAll(_projectionWriters.Select(pw => pw.AddAsync(@event.Subject, () => new Document { Id = @event.Subject, TranslationType = @event.TranslationType, TranslationOptionSubject = @event.TranslationSubject, FileName = @event.FileName, Version = 1 }, cancellationToken))); }
private async Task HandleAsync(DocumentUploaded @event, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { _logger.LogInformation($"{nameof(DocumentProjectionManager)}.{nameof(HandleAsync)} was cancelled before execution"); cancellationToken.ThrowIfCancellationRequested(); } await Task.WhenAll(_projectionWriters.Select(pw => pw.UpdateAsync(@event.User, userDocuments => { var documents = userDocuments.Documents.ToList(); documents.Add(new UserDocument { DocumentId = @event.Subject, FileName = @event.FileName }); userDocuments.Documents = documents; }, cancellationToken))); }
private async Task HandleAsync(DocumentUploaded @event, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { _logger.LogInformation($"{nameof(DocumentProjectionManager)}.{nameof(HandleAsync)} was cancelled before execution"); cancellationToken.ThrowIfCancellationRequested(); } await Task.WhenAll(_projectionWriters.Select(pw => pw.AddAsync(@event.Subject, () => new Audit { Subject = @event.Subject, Events = new AuditEvent[] { new AuditEvent { Id = Subject.New(), TimeStamp = @event.Timestamp, User = @event.User, Message = "Document uploaded" } } }, cancellationToken))); }
protected override async Task Given() { var @event = new DocumentUploaded(_eventFixture.Id, _eventFixture.AggregateId, new Guid(_eventFixture.UserId), _eventFixture.TranslationType, _eventFixture.TranslationSubject, _eventFixture.FileName); await Translation.HandleAsync(@event); }
public ActionResult UpdateFileDetails(BuyerDetailViewModel vm) { List <DocumentUploaded> dm = new List <DocumentUploaded>(); var AddressDetailFileCount = db.DocumentUploadeds.Where(x => x.BuyerId == vm.BuyerId && x.FileType == 1).Count(); var ApplicationDetailFileCount = db.DocumentUploadeds.Where(x => x.BuyerId == vm.BuyerId && x.FileType == 2).Count(); var IncomeProofDetailFileCount = db.DocumentUploadeds.Where(x => x.BuyerId == vm.BuyerId && x.FileType == 3).Count(); var BankStatementDetailFileCount = db.DocumentUploadeds.Where(x => x.BuyerId == vm.BuyerId && x.FileType == 4).Count(); var IdentityProofDetailFileCount = db.DocumentUploadeds.Where(x => x.BuyerId == vm.BuyerId && x.FileType == 5).Count(); var ProfileDetailFileCount = db.DocumentUploadeds.Where(x => x.BuyerId == vm.BuyerId && x.FileType == 6).Count(); var CheckAddressDetailCount = AddressDetailFileCount + vm.addressProof.Count(); var CheckApplicationDetailCount = ApplicationDetailFileCount + vm.applicationForm.Count(); var CheckIncomeProofDetailCount = IncomeProofDetailFileCount + vm.incomeProof.Count(); var CheckBankStatementDetailCount = BankStatementDetailFileCount + vm.bankStatement.Count(); var CheckIndentityDetailCount = IdentityProofDetailFileCount + vm.identityProof.Count(); var CheckProfileDetailCount = ProfileDetailFileCount + vm.profileDocumet.Count(); if (vm.addressProof != null && CheckAddressDetailCount <= 5) { foreach (var fileitem in vm.addressProof) { if (fileitem != null) { var fileName = Path.GetFileName(fileitem.FileName); var docDetail = new DocumentUploaded { BuyerId = vm.BuyerId, FileName = fileName, FileType = 1 }; dm.Add(docDetail); var serverPath = Path.Combine(Server.MapPath("~/Content/Files"), fileName); fileitem.SaveAs(serverPath); } } foreach (var item in dm) { db.DocumentUploadeds.Add(item); } } else { ViewBag.Message = "The No Of Files You are Uploading and Already Uploaded Should Not Exceed More Than 5"; } if (vm.applicationForm != null && CheckApplicationDetailCount <= 5) { foreach (var fileitem in vm.applicationForm) { if (fileitem != null) { var fileName = Path.GetFileName(fileitem.FileName); var docDetail = new DocumentUploaded { BuyerId = vm.BuyerId, FileName = fileName, FileType = 2 }; dm.Add(docDetail); var serverPath = Path.Combine(Server.MapPath("~/Content/Files"), fileName); fileitem.SaveAs(serverPath); } } foreach (var item in dm) { db.DocumentUploadeds.Add(item); } } if (vm.incomeProof != null && CheckIncomeProofDetailCount <= 5) { foreach (var fileitem in vm.incomeProof) { if (fileitem != null) { var fileName = Path.GetFileName(fileitem.FileName); var docDetail = new DocumentUploaded { BuyerId = vm.BuyerId, FileName = fileName, FileType = 3 }; dm.Add(docDetail); var serverPath = Path.Combine(Server.MapPath("~/Content/Files"), fileName); fileitem.SaveAs(serverPath); } } foreach (var item in dm) { db.DocumentUploadeds.Add(item); } } if (vm.bankStatement != null && CheckBankStatementDetailCount <= 5) { foreach (var fileitem in vm.bankStatement) { if (fileitem != null) { var fileName = Path.GetFileName(fileitem.FileName); var docDetail = new DocumentUploaded { BuyerId = vm.BuyerId, FileName = fileName, FileType = 4 }; dm.Add(docDetail); var serverPath = Path.Combine(Server.MapPath("~/Content/Files"), fileName); fileitem.SaveAs(serverPath); } } foreach (var item in dm) { db.DocumentUploadeds.Add(item); } } if (vm.identityProof != null && CheckIndentityDetailCount <= 5) { foreach (var fileitem in vm.identityProof) { if (fileitem != null) { var fileName = Path.GetFileName(fileitem.FileName); var docDetail = new DocumentUploaded { BuyerId = vm.BuyerId, FileName = fileName, FileType = 5 }; dm.Add(docDetail); var serverPath = Path.Combine(Server.MapPath("~/Content/Files"), fileName); fileitem.SaveAs(serverPath); } } foreach (var item in dm) { db.DocumentUploadeds.Add(item); } } if (vm.profileDocumet != null && CheckProfileDetailCount <= 5) { foreach (var fileitem in vm.profileDocumet) { if (fileitem != null) { var fileName = Path.GetFileName(fileitem.FileName); var docDetail = new DocumentUploaded { BuyerId = vm.BuyerId, FileName = fileName, FileType = 6 }; dm.Add(docDetail); var serverPath = Path.Combine(Server.MapPath("~/Content/Files"), fileName); fileitem.SaveAs(serverPath); } } foreach (var item in dm) { db.DocumentUploadeds.Add(item); } } var buyerDocuments = db.BuyerDocuments.Where(x => x.BuyerId == vm.BuyerId).FirstOrDefault(); if (buyerDocuments != null) { //Address Proof Details buyerDocuments.PassportCopy = vm.PassportCopy; buyerDocuments.DrivingLicenceWithDob = vm.DrivingLicenceWithDob; buyerDocuments.VotersId = vm.VotersId; buyerDocuments.ElectricityBill = vm.ElectricityBill; buyerDocuments.TelephoneBill = vm.TelephoneBill; buyerDocuments.LeaveLicenceAggrCopy = vm.LeaveLicenceAggrCopy; buyerDocuments.CompanyAccoLetter = vm.CompanyAccoLetter; buyerDocuments.OtherBankStatmnt = vm.OtherBankStatmnt; buyerDocuments.TelephoneProof = vm.TelephoneProof; buyerDocuments.AadharCardCopy = vm.AadharCardCopy; buyerDocuments.AddressDetailId = vm.AddressProofDetailId; //Application Form Details buyerDocuments.ApplicationFormImaging = vm.ApplicationFormImaging; buyerDocuments.ApplicationFormDetailId = vm.ApplicationFormDetailId; //Income Proof buyerDocuments.Form16 = vm.Form16; buyerDocuments.AppointmentLetter = vm.AppointmentLetter; buyerDocuments.SalarySlip = vm.SalarySlip; buyerDocuments.Itr = vm.Itr; buyerDocuments.GstCertification = vm.GstCertification; buyerDocuments.IncomeProofDetailId = vm.IncomeProofDetailId; //Bank Statement buyerDocuments.BankStatementDetailId = vm.BankStatementDetailId; buyerDocuments.BankStatementLatestSixMonths = vm.BankStatementLatestSixMonths; buyerDocuments.BankStatmentThreeMonths = vm.BankStatmentThreeMonths; buyerDocuments.BankStatementYear = vm.BankStatementYear; //Identity Proof buyerDocuments.VotersIdCard = vm.VotersIdCard; buyerDocuments.IdentityProofDetailId = vm.IdentityProofDetailId; //Profile Documents buyerDocuments.PanCardId = vm.PanCardId; buyerDocuments.ProfilePhoto = vm.ProfilePhoto; buyerDocuments.ProfileDocumentDetailId = vm.ProfileDocumentDetailId; } else { var buyerDocChecks = new FileUploadDetails { PassportCopy = vm.PassportCopy, DrivingLicenceWithDob = vm.DrivingLicenceWithDob, VotersId = vm.VotersId, ElectricityBill = vm.ElectricityBill, TelephoneBill = vm.TelephoneBill, LeaveLicenceAggrCopy = vm.LeaveLicenceAggrCopy, CompanyAccoLetter = vm.CompanyAccoLetter, OtherBankStatmnt = vm.OtherBankStatmnt, TelephoneProof = vm.TelephoneProof, AadharCardCopy = vm.AadharCardCopy, BuyerId = vm.BuyerId, AddressDetailId = 1, //Application Form Details ApplicationFormImaging = vm.ApplicationFormImaging, ApplicationFormDetailId = 2, //Income Proof Form16 = vm.Form16, AppointmentLetter = vm.AppointmentLetter, SalarySlip = vm.SalarySlip, Itr = vm.Itr, GstCertification = vm.GstCertification, IncomeProofDetailId = 3, //Bank Statement BankStatementDetailId = 4, BankStatementLatestSixMonths = vm.BankStatementLatestSixMonths, BankStatmentThreeMonths = vm.BankStatmentThreeMonths, BankStatementYear = vm.BankStatementYear, //Identity Proof VotersIdCard = vm.VotersIdCard, IdentityProofDetailId = 5, //Profile Documents PanCardId = vm.PanCardId, ProfilePhoto = vm.ProfilePhoto, ProfileDocumentDetailId = 6 }; db.BuyerDocuments.Add(buyerDocChecks); } Comments newcomment = new Comments(); newcomment.BuyerId = vm.BuyerId; newcomment.CommentDetails = vm.PersonalComments; newcomment.CommentDateTime = DateTime.Now; db.Comments.Add(newcomment); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Apply(DocumentUploaded evt) { _documentBlobId = evt.BlobId; }
public void AssociateWithDocumentBlob(Guid blobId) { var evt = new DocumentUploaded(blobId, Id, Version + 1); RaiseEvent(evt); }