EA.Iws.Domain.Movement.CapturedMovementFactory.Create C# (CSharp) Method

Create() public method

public Create ( System.Guid notificationId, int number, System.DateTime prenotificationDate, System.DateTime actualShipmentDate, bool hasNoPrenotification ) : Task
notificationId System.Guid
number int
prenotificationDate System.DateTime
actualShipmentDate System.DateTime
hasNoPrenotification bool
return Task
        public async Task<Movement> Create(Guid notificationId, int number, DateTime? prenotificationDate, DateTime actualShipmentDate, bool hasNoPrenotification)
        {
            if (hasNoPrenotification && prenotificationDate.HasValue)
            {
                throw new ArgumentException("Can't provide prenotification date if there is no prenotification", "prenotificationDate");
            }

            if (!await movementNumberValidator.Validate(notificationId, number))
            {
                throw new MovementNumberException("Cannot create a movement with a conflicting movement number (" + number + ") for notification: " + notificationId);
            }

            var notificationStatus = (await assessmentRepository.GetByNotificationId(notificationId)).Status;

            if (notificationStatus != NotificationStatus.Consented)
            {
                throw new InvalidOperationException(
                    string.Format("Cannot create a movement for notification {0} because its status is {1}",
                        notificationId, notificationStatus));
            }

            var movement = Movement.Capture(number, notificationId, actualShipmentDate, prenotificationDate, hasNoPrenotification, userContext.UserId);

            return movement;
        }
    }
CapturedMovementFactory