コード例 #1
0
        public static PaymentIn ToWebModel(this VirtoCommerceOrderModuleWebModelPaymentIn paymentIn, IEnumerable <Currency> availCurrencies, Language language)
        {
            var webModel = new PaymentIn();

            var currency = availCurrencies.FirstOrDefault(x => x.Equals(paymentIn.Currency)) ?? new Currency(language, paymentIn.Currency);

            webModel.InjectFrom(paymentIn);

            if (paymentIn.ChildrenOperations != null)
            {
                webModel.ChildrenOperations = paymentIn.ChildrenOperations.Select(co => co.ToWebModel(availCurrencies, language)).ToList();
            }

            webModel.Currency = currency;

            if (paymentIn.DynamicProperties != null)
            {
                webModel.DynamicProperties = paymentIn.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            webModel.Sum = new Money(paymentIn.Sum ?? 0, currency);
            webModel.Tax = new Money(paymentIn.Tax ?? 0, currency);

            return(webModel);
        }
コード例 #2
0
        public static PaymentIn ToCoreModel(this PaymentInEntity entity, IEnumerable <PaymentMethod> paymentMethods)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var retVal = new PaymentIn();

            retVal.InjectFrom(entity);
            retVal.Currency      = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);
            retVal.PaymentStatus = EnumUtility.SafeParse <PaymentStatus>(entity.Status, PaymentStatus.Custom);

            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
            }

            if (paymentMethods != null)
            {
                retVal.PaymentMethod = paymentMethods.FirstOrDefault(x => String.Equals(x.Code, entity.GatewayCode, StringComparison.InvariantCultureIgnoreCase));
            }

            return(retVal);
        }
コード例 #3
0
        public virtual PaymentIn ToOrderInPayment(orderDto.PaymentIn paymentIn, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(paymentIn.Currency)) ?? new Currency(language, paymentIn.Currency);
            var retVal   = new PaymentIn(currency);

            retVal.InjectFrom(paymentIn);

            if (paymentIn.BillingAddress != null)
            {
                retVal.BillingAddress = paymentIn.BillingAddress.ToAddress();
            }

            if (paymentIn.DynamicProperties != null)
            {
                retVal.DynamicProperties = paymentIn.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            retVal.Sum = new Money(paymentIn.Sum ?? 0, currency);

            if (paymentIn.PaymentMethod != null)
            {
                retVal.GatewayCode = paymentIn.PaymentMethod.Code;
            }
            return(retVal);
        }
コード例 #4
0
        public static PaymentIn ToWebModel(this VirtoCommerceOrderModuleWebModelPaymentIn paymentIn)
        {
            var webModel = new PaymentIn();

            var currency = new Currency(EnumUtility.SafeParse(paymentIn.Currency, CurrencyCodes.USD));

            webModel.InjectFrom(paymentIn);

            if (paymentIn.ChildrenOperations != null)
            {
                webModel.ChildrenOperations = paymentIn.ChildrenOperations.Select(co => co.ToWebModel()).ToList();
            }

            webModel.Currency = currency;

            if (paymentIn.DynamicProperties != null)
            {
                webModel.DynamicProperties = paymentIn.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            webModel.Sum = new Money(paymentIn.Sum ?? 0, currency.Code);
            webModel.Tax = new Money(paymentIn.Tax ?? 0, currency.Code);

            return(webModel);
        }
コード例 #5
0
        public static PaymentIn ToCoreModel(this PaymentInEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var retVal = new PaymentIn();

            retVal.InjectFrom(entity);
            retVal.Currency      = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);
            retVal.PaymentStatus = EnumUtility.SafeParse <PaymentStatus>(entity.Status, PaymentStatus.Custom);

            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
            }
            return(retVal);
        }
コード例 #6
0
        public static PaymentIn ToCoreModel(this coreModel.Payment payment)
        {
            if (payment == null)
            {
                throw new ArgumentNullException("payment");
            }

            var retVal = new PaymentIn();

            retVal.InjectFrom(payment);
            retVal.Currency    = payment.Currency;
            retVal.GatewayCode = payment.PaymentGatewayCode;
            retVal.Sum         = payment.Amount;

            if (payment.BillingAddress != null)
            {
                retVal.BillingAddress = payment.BillingAddress.ToCoreModel();
            }

            return(retVal);
        }
コード例 #7
0
        public static PaymentIn ToCoreModel(this PaymentInEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var retVal = new PaymentIn();

            retVal.InjectFrom(entity);
            retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);

            if (entity.Properties != null)
            {
                retVal.Properties = entity.Properties.Select(x => x.ToCoreModel()).ToList();
            }

            if (entity.Addresses != null && entity.Addresses.Any())
            {
                retVal.BillingAddress = entity.Addresses.First().ToCoreModel();
            }
            return(retVal);
        }