コード例 #1
0
        public CreateMovementsViewModel(ShipmentInfo shipmentInfo)
        {
            StartDate         = shipmentInfo.ShipmentDates.StartDate;
            EndDate           = shipmentInfo.ShipmentDates.EndDate;
            NotificationUnits = shipmentInfo.ShipmentQuantityUnits;
            AvailableUnits    = ShipmentQuantityUnitsMetadata.GetUnitsOfThisType(shipmentInfo.ShipmentQuantityUnits).ToList();

            var items = shipmentInfo.PackagingData.PackagingTypes
                        .Where(x => x != PackagingType.Other)
                        .Select(x => new SelectListItem
            {
                Text  = EnumHelper.GetDisplayName(x),
                Value = ((int)x).ToString()
            })
                        .ToList();

            if (shipmentInfo.PackagingData.PackagingTypes.Contains(PackagingType.Other))
            {
                items.Add(new SelectListItem
                {
                    Text = string.Format("{0} - {1}", EnumHelper.GetShortName(PackagingType.Other),
                                         shipmentInfo.PackagingData.OtherDescription),
                    Value = ((int)PackagingType.Other).ToString()
                });
            }

            PackagingTypes = new CheckBoxCollectionViewModel();
            PackagingTypes.ShowEnumValue  = true;
            PackagingTypes.PossibleValues = items;
        }
コード例 #2
0
ファイル: MovementDataMap.cs プロジェクト: DEFRA/prsd-iws
        private static ImportMovementReceiptData GetReceiptData(ImportMovementSummary source)
        {
            var possibleUnits = ShipmentQuantityUnitsMetadata.GetUnitsOfThisType(source.Units).ToArray();

            if (source.Rejection != null)
            {
                return(new ImportMovementReceiptData
                {
                    PossibleUnits = possibleUnits,
                    RejectionReason = source.Rejection.Reason,
                    ReceiptDate = source.Rejection.Date,
                    IsRejected = true
                });
            }

            if (source.Receipt != null)
            {
                return(new ImportMovementReceiptData
                {
                    PossibleUnits = possibleUnits,
                    ReceiptDate = source.Receipt.Date,
                    ActualQuantity = source.Receipt.Quantity,
                    IsReceived = true,
                    ReceiptUnits = source.Receipt.Unit
                });
            }

            return(new ImportMovementReceiptData
            {
                IsReceived = false,
                PossibleUnits = possibleUnits,
                NotificationUnit = source.Units
            });
        }
コード例 #3
0
        public async Task <PrenotificationContentRuleResult <PrenotificationContentRules> > GetResult(
            List <PrenotificationMovement> movements, Guid notificationId)
        {
            var shipment = await shipmentInfoRepository.GetByNotificationId(notificationId);

            var units          = shipment == null ? default(ShipmentQuantityUnits) : shipment.Units;
            var availableUnits = ShipmentQuantityUnitsMetadata.GetUnitsOfThisType(units).ToList();

            return(await Task.Run(() =>
            {
                var shipments =
                    movements.Where(
                        m =>
                        m.ShipmentNumber.HasValue &&
                        (!m.Unit.HasValue ||
                         availableUnits.All(u => u != m.Unit.Value)))
                    .GroupBy(x => x.ShipmentNumber)
                    .OrderBy(x => x.Key)
                    .Select(x => x.Key)
                    .ToList();

                var result = shipments.Any() ? MessageLevel.Error : MessageLevel.Success;
                var minShipment = shipments.FirstOrDefault() ?? 0;

                var shipmentNumbers = string.Join(", ", shipments);
                var errorMessage =
                    string.Format(
                        Prsd.Core.Helpers.EnumHelper.GetDisplayName(PrenotificationContentRules.QuantityUnit),
                        shipmentNumbers);

                return new PrenotificationContentRuleResult <PrenotificationContentRules>(PrenotificationContentRules.QuantityUnit, result, errorMessage, minShipment);
            }));
        }
コード例 #4
0
        public async Task <MovementReceiptAndRecoveryData> HandleAsync(GetMovementReceiptAndRecoveryData message)
        {
            var movement = await movementRepository.GetById(message.MovementId);

            var notification = await notificationApplicationRepository.GetById(movement.NotificationId);

            var movementRejection = await movementRejectionRepository.GetByMovementIdOrDefault(movement.Id);

            var shipmentInfo = await shipmentInfoRepository.GetByNotificationId(notification.Id);

            var data = new MovementReceiptAndRecoveryData
            {
                Id                  = movement.Id,
                NotificationId      = notification.Id,
                Number              = movement.Number,
                PossibleUnits       = ShipmentQuantityUnitsMetadata.GetUnitsOfThisType(shipmentInfo.Units).ToArray(),
                ActualDate          = movement.Date,
                NotificationType    = notification.NotificationType,
                PrenotificationDate = movement.PrenotificationDate,
                NotificationUnits   = shipmentInfo.Units,
                Status              = movement.Status,
                Comments            = movement.Comments,
                StatsMarking        = movement.StatsMarking
            };

            if (movement.Receipt != null)
            {
                data.ReceiptDate    = movement.Receipt.Date;
                data.ActualQuantity = movement.Receipt.QuantityReceived.Quantity;
                data.ReceiptUnits   = movement.Receipt.QuantityReceived.Units;
                data.IsReceived     = true;
            }

            if (movement.CompletedReceipt != null)
            {
                data.OperationCompleteDate = movement.CompletedReceipt.Date;
                data.IsOperationCompleted  = true;
            }

            if (movementRejection != null)
            {
                data.RejectionReason = movementRejection.Reason;
                data.ReceiptDate     = movementRejection.Date;
                data.IsRejected      = true;
            }

            return(data);
        }
コード例 #5
0
        public async Task <ActionResult> Create(Guid id, int?shipmentNumber = null)
        {
            var model = new CaptureViewModel();

            if (shipmentNumber.HasValue)
            {
                model.ShipmentNumber = shipmentNumber;
            }

            var result = await mediator.SendAsync(new GetNotificationDetails(id));

            model.Recovery.NotificationType = result.NotificationType;
            model.NotificationType          = result.NotificationType;
            //Set the units based on the notification Id
            var units = await mediator.SendAsync(new GetImportShipmentUnits(id));

            model.Receipt.PossibleUnits = ShipmentQuantityUnitsMetadata.GetUnitsOfThisType(units).ToArray();
            await UpdateSummary(model, id);

            return(View(model));
        }