Пример #1
0
        public static Mock <IShippingService> CreateMockShippingService(ShippingSlip shippingSlip)
        {
            var mockShippingService = new Mock <IShippingService>();

            mockShippingService.Setup(shippingService => shippingService.GenerateShippingSlipAsync(It.IsAny <int>(), It.IsAny <IEnumerable <IPurchaseItem> >())).Returns(Task.FromResult(shippingSlip));

            return(mockShippingService);
        }
Пример #2
0
 public ShippingSlipLine(ShippingSlip shipping, Product product, int quantity)
 {
     ShippingSlip   = shipping ?? throw new ArgumentNullException(nameof(shipping));
     ShippingSlipId = shipping.Id;
     Product        = product ?? throw new ArgumentNullException(nameof(product));
     ProductId      = product.Id;
     Quantity       = quantity;
 }
Пример #3
0
        public void CreateShippingSlip(IProduct product, Customer customer)
        {
            var shippingSlip = new ShippingSlip
            {
                Customer        = customer,
                Product         = product,
                ShippingAddress = customer.ShippingAddress
            };

            _repository.SaveShippingSlip(shippingSlip);
        }
Пример #4
0
        public async Task Handle(OrderedPhysicalProductDomainEvent orderEvent, CancellationToken cancellationToken)
        {
            if (!orderEvent.Order.Lines.Any(x => x.Product.Type == ProductType.Book || x.Product.Type == ProductType.Video))
            {
                return;
            }

            ShippingSlip shippingSlip = new ShippingSlip(orderEvent.CustomerId, "Street 1, 123", orderEvent.Order);

            _shippingSlipRepository.Add(shippingSlip);
            await _shippingSlipRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
        }
        public async Task ProcessAsync(PurchaseOrder order, PurchaseOrderLine line)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }

            order.Validate();
            if (!CanProcess(line.Product))
            {
                throw new NotSupportedException(nameof(line.Product));
            }

            await Task.Factory.StartNew(() =>
            {
                ShippingSlip shippingSlip = new ShippingSlip(order.OrderNumber);
                order.ShippingSlip        = shippingSlip;
            });
        }
Пример #6
0
 public IPOModifier CreateShippingSlip()
 {
     Slip = new ShippingSlip();
     return(this);
 }
Пример #7
0
 public ShippingSlip Update(ShippingSlip ShippingSlip)
 {
     return(_context.ShippingSlips
            .Update(ShippingSlip)
            .Entity);
 }
Пример #8
0
 public ShippingSlip Add(ShippingSlip ShippingSlip)
 {
     return(_context.ShippingSlips
            .Add(ShippingSlip)
            .Entity);
 }
Пример #9
0
 public void SaveShippingSlip(ShippingSlip shippingSlip)
 {
     shippingSlips.Add(shippingSlip);
 }