예제 #1
0
    public virtual async Task HandleEventAsync(OrderPaidEto eventData)
    {
        var occupyModels           = new List <OccupyAssetInfoModel>();
        var occupyByCategoryModels = new List <OccupyAssetByCategoryInfoModel>();

        foreach (var orderLine in eventData.Order.OrderLines)
        {
            var assetId         = orderLine.FindBookingAssetId();
            var assetCategoryId = orderLine.FindBookingAssetCategoryId();
            var volume          = orderLine.FindBookingVolume();
            var date            = orderLine.FindBookingDate();
            var startingTime    = orderLine.FindBookingStartingTime();
            var duration        = orderLine.FindBookingDuration();

            if (volume is null || date is null || startingTime is null || duration is null)
            {
                continue;
            }

            if (assetId.HasValue)
            {
                occupyModels.Add(new OccupyAssetInfoModel(
                                     assetId: assetId.Value,
                                     volume: volume.Value,
                                     date: date.Value,
                                     startingTime: startingTime.Value,
                                     duration: duration.Value
                                     ));
            }
            else if (assetCategoryId.HasValue)
            {
                occupyByCategoryModels.Add(new OccupyAssetByCategoryInfoModel(
                                               assetCategoryId: assetCategoryId.Value,
                                               volume: volume.Value,
                                               date: date.Value,
                                               startingTime: startingTime.Value,
                                               duration: duration.Value
                                               ));
            }
        }

        var eto = new BulkOccupyAssetEto(eventData.TenantId, eventData.Order.Id, eventData.Order.CustomerUserId,
                                         occupyModels, occupyByCategoryModels);

        eto.SetBookingOrderId(eventData.Order.Id);

        await _distributedEventBus.PublishAsync(eto);
    }
예제 #2
0
 public static Guid?FindBookingOrderId(this BulkOccupyAssetEto eto)
 {
     return(eto.GetProperty <Guid?>(BulkOccupyAssetEtoProperties.BookingOrderId));
 }
예제 #3
0
 public static void SetBookingOrderId(this BulkOccupyAssetEto eto, Guid?value)
 {
     eto.SetProperty(BulkOccupyAssetEtoProperties.BookingOrderId, value);
 }