Exemplo n.º 1
0
        /// <summary>
        /// Value to pass to the notification monitors
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="contacts">
        /// An additional list of contacts
        /// </param>
        protected override void Notify(IPaymentResult model, IEnumerable <string> contacts)
        {
            var         symbol     = string.Empty;
            IShipment   shipment   = null;
            IShipMethod shipMethod = null;

            if (model.Invoice != null)
            {
                if (model.Invoice.Items.Any())
                {
                    var currencyCode =
                        model.Invoice.Items.First().ExtendedData.GetValue(Core.Constants.ExtendedDataKeys.CurrencyCode);
                    var currency = _storeSettingService.GetCurrencyByCode(currencyCode);
                    symbol = currency.Symbol;
                }


                // get shipping information if any

                var shippingLineItems = model.Invoice.ShippingLineItems().ToArray();
                if (shippingLineItems.Any())
                {
                    // just use the first one
                    shipment = shippingLineItems.First().ExtendedData.GetShipment <InvoiceLineItem>();

                    // get the shipmethod information
                    if (shipment != null && shipment.ShipMethodKey.HasValue)
                    {
                        shipMethod = _shipMethodService.GetByKey(shipment.ShipMethodKey.Value);
                    }
                }
            }

            NotifyMonitors(model.ToOrderConfirmationNotification(contacts, shipment, shipMethod, symbol));
        }
        /// <summary>
        /// The build.
        /// </summary>
        /// <param name="shipment">
        /// The shipment.
        /// </param>
        /// <returns>
        /// The <see cref="IShipmentResultNotifyModel"/>.
        /// </returns>
        public IShipmentResultNotifyModel Build(IShipment shipment)
        {
            var notifyModel = new ShipmentResultNotifyModel()
            {
                Shipment = shipment
            };
            var item = shipment.Items.FirstOrDefault(x => !x.ContainerKey.Equals(Guid.Empty));

            if (item != null)
            {
                var orderKey = item.ContainerKey;

                var order = _orderService.GetByKey(orderKey);

                if (order != null)
                {
                    var invoice = _invoiceService.GetByKey(order.InvoiceKey);
                    if (invoice != null)
                    {
                        notifyModel.Invoice = invoice;
                        if (invoice.Items.Any())
                        {
                            var currencyCode =
                                invoice.Items.First()
                                .ExtendedData.GetValue(Core.Constants.ExtendedDataKeys.CurrencyCode);
                            var currency = _storeSettingService.GetCurrencyByCode(currencyCode);
                            notifyModel.CurrencySymbol = currency.Symbol;
                        }
                    }
                }
            }

            return(notifyModel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// The initialize.
        /// </summary>
        private void Initialize()
        {
            var setting = _storeSettingService.GetByKey(Core.Constants.StoreSettingKeys.CurrencyCodeKey);

            _currency = _storeSettingService.GetCurrencyByCode(setting.Value);
        }