Inheritance: System.Entity
示例#1
0
        public static Movement Capture(int movementNumber, Guid notificationId, DateTime actualDate,
            DateTime? prenotificationDate, bool hasNoPrenotification, Guid createdBy)
        {
            if (hasNoPrenotification && prenotificationDate.HasValue)
            {
                throw new ArgumentException("Can't provide prenotification date if there is no prenotification", "prenotificationDate");
            }

            var movement = new Movement
            {
                NotificationId = notificationId,
                Number = movementNumber,
                Date = actualDate,
                Status = MovementStatus.Captured,
                HasNoPrenotification = hasNoPrenotification,
                CreatedBy = createdBy.ToString()
            };

            if (prenotificationDate.HasValue)
            {
                movement.SubmitInternally(prenotificationDate.Value);
            }

            return movement;
        }
        public async Task<string> GetValue(Movement movement)
        {
            var notification = await notificationRepository.GetById(movement.NotificationId);
            var notificationNumber = notification.NotificationNumber.Replace(" ", string.Empty);
            var notificationType = notification.NotificationType.ToString().ToLowerInvariant();

            return string.Format(nameFormat, notificationNumber, movement.Number, notificationType);
        }
 public async Task<File> CreateForMovement(ICertificateNameGenerator nameGenerator, 
     Movement movement, 
     byte[] content, 
     string fileType)
 {
     var fileName = await nameGenerator.GetValue(movement);
     return new File(fileName, fileType, content);
 }
        public async Task<MovementDetails> Create(Movement movement, ShipmentQuantity shipmentQuantity, IEnumerable<PackagingInfo> packages)
        {
            var remaining = await movementsQuantity.Remaining(movement.NotificationId);

            if (shipmentQuantity > remaining)
            {
                throw new InvalidOperationException(string.Format(
                    "Cannot create new movement details for movement {0} as the quantity exceeds what is remaining", movement.Id));
            }

            return new MovementDetails(movement.Id, shipmentQuantity, packages);
        }
        public async Task<DateTime> Get(Movement movement)
        {
            var previousDates = await historyRepository.GetByMovementId(movement.Id);

            if (!previousDates.Any())
            {
                return movement.Date;
            }

            return previousDates
                .OrderBy(d => d.DateChanged)
                .Select(d => d.PreviousDate.Date)
                .First();
        }
 public MovementStatusChangeEvent(Movement movement, MovementStatus targetStatus)
 {
     TargetStatus = targetStatus;
     Movement = movement;
 }
 public async Task<string> GetValue(Movement movement)
 {
     var notification = await notificationApplicationRepository.GetById(movement.NotificationId);
     var notificationNumber = notification.NotificationNumber.Replace(" ", string.Empty);
     return string.Format(nameFormat, notificationNumber, movement.Number);
 }