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); }
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); }
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); }
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); }
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); }
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); }
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); }