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;
}
}