public async Task <FinancialGuaranteeData> HandleAsync(GetCurrentFinancialGuaranteeDetails message)
        {
            var financialGuaranteeCollection = await financialGuaranteeRepository.GetByNotificationId(message.NotificationId);

            var financialGuarantee = financialGuaranteeCollection.GetLatestFinancialGuarantee();
            var authority          = (await notificationApplicationRepository.GetById(message.NotificationId)).CompetentAuthority;
            var notificationStatus = await assessmentRepository.GetStatusByNotificationId(message.NotificationId);

            var result = financialGuaranteeMap.Map(financialGuarantee, authority);

            result.IsNotificationStatusRecordable = IsRecordableStatus(notificationStatus);

            return(result);
        }
예제 #2
0
        public async Task <WhatToDoNextPaymentData> HandleAsync(GetWhatToDoNextPaymentDataForNotification message)
        {
            var notification = await context.GetNotificationApplication(message.Id);

            var competentAuthority = await context.UnitedKingdomCompetentAuthorities.SingleAsync(
                n => n.Id == (int)notification.CompetentAuthority);

            var result = map.Map(notification, competentAuthority);

            result.Status = await assessmentRepository.GetStatusByNotificationId(message.Id);

            result.Charge = await chargeCalculator.GetValue(message.Id);

            result.AmountPaid = await transactionCalculator.TotalPaid(message.Id);

            return(result);
        }
        public async Task <Guid> HandleAsync(SetIntendedShipmentInfoForNotification command)
        {
            var facilityCollection = await facilityRepository.GetByNotificationId(command.NotificationId);

            var shipmentInfo = await shipmentInfoRepository.GetByNotificationId(command.NotificationId);

            var status = await assessmentRepository.GetStatusByNotificationId(command.NotificationId);

            var shipmentPeriod = new ShipmentPeriod(
                command.StartDate,
                command.EndDate,
                facilityCollection.AllFacilitiesPreconsented.GetValueOrDefault());

            var shipmentQuantity = new ShipmentQuantity(
                command.Quantity,
                command.Units);

            if (shipmentInfo == null)
            {
                shipmentInfo = new ShipmentInfo(command.NotificationId,
                                                shipmentPeriod,
                                                command.NumberOfShipments,
                                                shipmentQuantity);

                context.ShipmentInfos.Add(shipmentInfo);
            }
            else
            {
                shipmentInfo.UpdateNumberOfShipments(command.NumberOfShipments);
                shipmentInfo.UpdateShipmentPeriod(shipmentPeriod, status);
                shipmentInfo.UpdateQuantity(shipmentQuantity);
            }

            await context.SaveChangesAsync();

            return(shipmentInfo.Id);
        }