コード例 #1
0
 public static ShipmentBookingDto ToDto(this ShipmentBooking shipmentBooking)
 => new ShipmentBookingDto
 {
     ShipmentBookingId = shipmentBooking.ShipmentBookingId,
     Name    = shipmentBooking.Name,
     Version = shipmentBooking.Version
 };
コード例 #2
0
            public async Task Handle(BookingCreated notification, CancellationToken cancellationToken)
            {
                var booking = notification.Booking;

                var customer = await _context
                               .Customers
                               .Include(x => x.CustomerLocations)
                               .ThenInclude(x => x.Location)
                               .SingleAsync(x => x.CustomerId == booking.CustomerId);

                var shippingBooking = new ShipmentBooking()
                {
                    BookingId = booking.BookingId
                };

                var shipment = new Shipment()
                {
                    Type = ShipmentType.Delivery,
                };

                var customerLocation = customer.CustomerLocations
                                       .SingleOrDefault(x => x.Location.Type == LocationType.Delivery ||
                                                        x.Location.Type == LocationType.DeliveryPickUp);

                if (customerLocation != null)
                {
                    shipment.LocationId = customerLocation.Location.LocationId;
                }

                shipment.ShipmentBookings.Add(shippingBooking);

                await _context.Shipments.AddAsync(shipment);

                await _context.SaveChangesAsync(cancellationToken);
            }
コード例 #3
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var shipmentBooking = await _context.ShipmentBookings.FindAsync(request.ShipmentBooking.ShipmentBookingId);

                if (shipmentBooking == null)
                {
                    shipmentBooking = new ShipmentBooking();
                    _context.ShipmentBookings.Add(shipmentBooking);
                }

                await _context.SaveChangesAsync(cancellationToken);

                return(new Response()
                {
                    ShipmentBookingId = shipmentBooking.ShipmentBookingId,
                    Version = shipmentBooking.Version
                });
            }