public void Handle(OrderReportCreated @event)
        {
            Action handling = () =>
            {
                using (var context = _contextFactory.Invoke())
                {
                    var existingReport = context.Find <OrderReportDetail>(@event.SourceId);
                    var orderReport    = existingReport ?? new OrderReportDetail {
                        Id = @event.SourceId
                    };

                    var account = context.Find <AccountDetail>(@event.AccountId);

                    orderReport.Account = new OrderReportAccount
                    {
                        AccountId        = @event.AccountId,
                        Name             = @event.Settings.Name,
                        Phone            = @event.Settings.Phone,
                        Email            = (account != null) ? account.Email : null,
                        DefaultCardToken = (account != null) ? account.DefaultCreditCard : null,
                        IBSAccountId     = (account != null) ? account.IBSAccountId : null,
                        PayBack          = (account != null) ? account.Settings.PayBack : null
                    };
                    orderReport.Order = new OrderReportOrder
                    {
                        IBSOrderId = @event.IBSOrderId,
                        ChargeType = @event.Settings.ChargeType,
                        IsChargeAccountPaymentWithCardOnFile = @event.IsChargeAccountPaymentWithCardOnFile,
                        IsPrepaid            = @event.IsPrepaid,
                        PickupDateTime       = @event.PickupDate,
                        CreateDateTime       = @event.CreatedDate,
                        PickupAddress        = @event.PickupAddress,
                        DropOffAddress       = @event.DropOffAddress,
                        CompanyName          = @event.CompanyName,
                        CompanyKey           = @event.CompanyKey,
                        Market               = @event.Market,
                        Error                = @event.Error,
                        OriginatingIpAddress = @event.OriginatingIpAddress,
                        KountSessionId       = @event.KountSessionId
                    };
                    orderReport.Client = new OrderReportClient
                    {
                        OperatingSystem = @event.UserAgent.GetOperatingSystem(),
                        UserAgent       = @event.UserAgent,
                        Version         = @event.ClientVersion
                    };

                    context.Save(orderReport);
                }
            };

            WrapWithSqlPrimaryKeyHandling(handling);
        }
Exemplo n.º 2
0
 public void OnOrderReportCreated(OrderReportCreated obj)
 {
     _status = OrderStatus.Unknown;
 }