public async Task <bool> HandleAsync(CancelImportMovements message)
        {
            var movementIds = message.CancelledMovements.Select(m => m.Id).ToList();

            movementIds.AddRange((await CaptureAddedImportMovements(message)).Select(m => m.Id));

            var movements =
                (await movementRepository.GetImportMovementsByIds(message.NotificationId, movementIds)).ToList();

            foreach (var movement in movements)
            {
                await cancelMovement.Cancel(movement.Id);
            }

            await context.SaveChangesAsync();

            foreach (var movement in movements)
            {
                await
                repository.Add(new ImportMovementAudit(message.NotificationId, movement.Number,
                                                       userContext.UserId.ToString().ToUpper(), (int)MovementAuditType.Cancelled,
                                                       SystemTime.Now.AddSeconds(AuditTimeOffSet)));
            }

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Add(ImportNotificationComment comment)
        {
            context.ImportNotificationComments.Add(comment);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #3
0
        public async Task <bool> HandleAsync(AuditImportMovement message)
        {
            await repository.Add(mapper.Map <ImportMovementAudit>(message));

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task HandleAsync(ImportNotificationStatusChangeEvent @event)
        {
            var userId = userContext.UserId;

            @event.Assessment.AddStatusChangeRecord(new ImportNotificationStatusChange(@event.Source, @event.Destination, userId));

            await context.SaveChangesAsync();
        }
        public async Task UpdateById(Guid id, string comment)
        {
            var existing = await context.ImportNotificationTransactions.Where(t => t.Id == id).SingleAsync();

            existing.UpdateComments(comment);

            await context.SaveChangesAsync();
        }
Beispiel #6
0
        public async Task <bool> HandleAsync(DeleteTransaction message)
        {
            await transaction.Delete(message.NotificationId, message.TransactionId);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #7
0
        public async Task <bool> HandleAsync(RecordReceipt message)
        {
            await receiveImportMovement.Receive(message.ImportMovementId, new ShipmentQuantity(message.Quantity, message.Unit), message.Date);

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> HandleAsync(ReleaseFinancialGuarantee message)
        {
            await releaseGuarantee.Release(new DecisionData(message.ImportNotificationId, message.DecisionDate));

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #9
0
        public async Task <bool> HandleAsync(UpdateInterimStatus message)
        {
            await repository.UpdateStatus(message.ImportNotificationId, message.IsInterim);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #10
0
        public async Task <bool> HandleAsync(CreateFinancialGuarantee message)
        {
            financialGuaranteeRepository.Add(new ImportFinancialGuarantee(message.ImportNotificationId,
                                                                          message.ReceivedDate));

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #11
0
        public async Task <Unit> HandleAsync(SetArchiveReference message)
        {
            var assessment = await repository.GetByNotification(message.NotificationId);

            assessment.SetArchiveReference(message.ArchiveReference);
            await context.SaveChangesAsync();

            return(Unit.Value);
        }
Beispiel #12
0
        public async Task HandleAsync(ImportFinancialGuaranteeStatusChangeEvent @event)
        {
            @event.Guarantee.AddStatusChangeRecord(new ImportFinancialGuaranteeStatusChange(@event.Source,
                                                                                            @event.Destination,
                                                                                            userContext.UserId,
                                                                                            DateTimeOffset.UtcNow));

            await context.SaveChangesAsync();
        }
        public async Task <Unit> HandleAsync(SetNotificationFileClosedDate message)
        {
            var assessment = await repository.GetByNotification(message.ImportNotificationId);

            assessment.MarkFileClosed(message.Date);
            await context.SaveChangesAsync();

            return(Unit.Value);
        }
Beispiel #14
0
        public async Task <bool> HandleAsync(WithdrawImportNotification message)
        {
            var result =
                await withdrawImportNotification.Withdraw(message.ImportNotificationId, message.Date, message.Reasons);

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> HandleAsync(RecordCompletedReceipt message)
        {
            await
            completeImportMovement.Complete(message.ImportMovementId,
                                            message.Date);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #16
0
        public async Task <bool> HandleAsync(AddNotificationRefund message)
        {
            await
            importRefundTransaction.Save(message.ImportNotificationId, message.Date, message.Amount,
                                         message.Comments);

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> HandleAsync(AddNotificationPayment message)
        {
            await
            importPaymentTransaction.Save(message.ImportNotificationId, message.Date, message.Amount,
                                          message.PaymentMethod, message.ReceiptNumber, message.Comments);

            await context.SaveChangesAsync();

            return(false);
        }
Beispiel #18
0
        public async Task <bool> HandleAsync(WithdrawConsentForImportNotification message)
        {
            var assessment = await repository.GetByNotification(message.Id);

            assessment.WithdrawConsent(message.Date, message.ReasonsForConsentWithdrawal);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #19
0
        public async Task <bool> HandleAsync(ApproveFinancialGuarantee message)
        {
            await
            approveFinancialGuarantee.Approve(new DecisionData(message.ImportNotificationId, message.DecisionDate),
                                              message.Reference);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #20
0
        public async Task <bool> HandleAsync(RecordRejection message)
        {
            await rejectImportMovement.Reject(message.ImportMovementId,
                                              message.Date,
                                              message.Reason);

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> HandleAsync(SetAssessmentStartedDate message)
        {
            var assessment = await assessmentRepository.GetByNotification(message.ImportNotificationId);

            assessment.BeginAssessment(message.Date, message.NameOfOfficer);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #22
0
        public async Task <bool> HandleAsync(RecordPartialOperationCompleteInternal message)
        {
            var movementPartial = await movementPartialRepository.GetByMovementId(message.Id);

            movementPartial.WasteDisposedDate = message.CompleteDate;

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #23
0
        public async Task <bool> HandleAsync(SetCompletedDate message)
        {
            var guarantee = await financialGuaranteeRepository.GetByNotificationId(message.ImportNotificationId);

            guarantee.Complete(message.Date);

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> HandleAsync(SetNotificationCompletedDate message)
        {
            var assessment = await repository.GetByNotification(message.ImportNotificationId);

            assessment.CompleteNotification(message.Date);

            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #25
0
        public async Task <bool> HandleAsync(Consent message)
        {
            await consentImportNotification.Consent(message.ImportNotificationId,
                                                    new DateRange(message.From, message.To),
                                                    message.Conditions,
                                                    message.Date);

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <Guid> HandleAsync(CreateImportNotification message)
        {
            var user = await internalUserRepository.GetByUserId(userContext.UserId);

            var notification = new ImportNotification(message.NotificationType, user.CompetentAuthority, message.Number);

            await importNotificationRepository.Add(notification);

            await context.SaveChangesAsync();

            var assessment = await assessmentRepository.GetByNotification(notification.Id);

            assessment.Receive(message.ReceivedDate);

            interimStatusRepository.Add(new InterimStatus(notification.Id, message.IsInterim));

            await context.SaveChangesAsync();

            return(notification.Id);
        }
Beispiel #27
0
        public async Task <Unit> HandleAsync(SetExitPoint message)
        {
            var transportRoute = await transportRouteRepository.GetByNotificationId(message.NotificationId);

            transportRoute.SetStateOfExport(new StateOfExport(message.ExitPointId,
                                                              transportRoute.StateOfExport.CompetentAuthorityId, transportRoute.StateOfExport.CountryId));

            await context.SaveChangesAsync();

            return(Unit.Value);
        }
Beispiel #28
0
        public async Task <bool> HandleAsync(SetNewNumberOfShipments message)
        {
            var shipment = await shipmentRepository.GetByNotificationId(message.NotificationId);

            shipment.UpdateNumberOfShipments(message.NewNumberOfShipments);

            shipmentHistotyRepository.Add(new NumberOfShipmentsHistory(message.NotificationId, message.OldNumberOfShipments, DateTime.UtcNow));

            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <Unit> HandleAsync(SetExporterDetailsForImportNotification message)
        {
            var exporter = await exporterRepository.GetByNotificationId(message.ImportNotificationId);

            var contact = mapper.Map <Contact>(message.ExporterDetails.Contact);

            exporter.UpdateContactAndName(contact, message.ExporterDetails.Name);

            await context.SaveChangesAsync();

            return(Unit.Value);
        }
Beispiel #30
0
        public async Task <Guid> HandleAsync(UpdateWasteOperation message)
        {
            var codes = message.OperationCodes.Select(x => new WasteOperationCode(x)).ToList();

            var wasteOperation = await wasteOperationRepository.GetByNotificationId(message.ImportNotificationId);

            wasteOperation.SetOperationCodes(codes);
            wasteOperation.SetTechnologyEmployed(message.TechnologyEmployed);

            await context.SaveChangesAsync();

            return(wasteOperation.Id);
        }