Esempio n. 1
0
        public virtual quoteDto.QuoteRequest ToQuoteRequestDto(QuoteRequest quoteRequest)
        {
            var serviceModel = new quoteDto.QuoteRequest();

            serviceModel.InjectFrom <NullableAndEnumValueInjecter>(quoteRequest);

            serviceModel.Currency                = quoteRequest.Currency.Code;
            serviceModel.Addresses               = quoteRequest.Addresses.Select(ToQuoteAddressDto).ToList();
            serviceModel.Attachments             = quoteRequest.Attachments.Select(ToQuoteAttachmentDto).ToList();
            serviceModel.DynamicProperties       = quoteRequest.DynamicProperties.Select(ToQuoteDynamicPropertyDto).ToList();
            serviceModel.Items                   = quoteRequest.Items.Select(ToQuoteItemDto).ToList();
            serviceModel.LanguageCode            = quoteRequest.Language.CultureName;
            serviceModel.ManualRelDiscountAmount = quoteRequest.ManualRelDiscountAmount != null ? (double?)quoteRequest.ManualRelDiscountAmount.Amount : null;
            serviceModel.ManualShippingTotal     = quoteRequest.ManualShippingTotal != null ? (double?)quoteRequest.ManualShippingTotal.Amount : null;
            serviceModel.ManualSubTotal          = quoteRequest.ManualSubTotal != null ? (double?)quoteRequest.ManualSubTotal.Amount : null;
            serviceModel.TaxDetails              = quoteRequest.TaxDetails.Select(ToQuoteTaxDetailDto).ToList();

            if (quoteRequest.Coupon != null && quoteRequest.Coupon.AppliedSuccessfully)
            {
                serviceModel.Coupon = quoteRequest.Coupon.Code;
            }

            if (quoteRequest.Totals != null)
            {
                serviceModel.Totals = ToQuoteTotalsDto(quoteRequest.Totals);
            }

            return(serviceModel);
        }
Esempio n. 2
0
        public virtual QuoteRequest ToQuoteRequest(quoteDto.QuoteRequest quoteRequestDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(quoteRequestDto.Currency)) ?? new Currency(language, quoteRequestDto.Currency);
            var result   = ServiceLocator.Current.GetInstance <QuoteFactory>().CreateQuoteRequest(currency, language);

            result.InjectFrom <NullableAndEnumValueInjecter>(quoteRequestDto);

            result.Currency = currency;
            result.Language = language;
            result.ManualRelDiscountAmount = new Money(quoteRequestDto.ManualRelDiscountAmount ?? 0, currency);
            result.ManualShippingTotal     = new Money(quoteRequestDto.ManualShippingTotal ?? 0, currency);
            result.ManualSubTotal          = new Money(quoteRequestDto.ManualSubTotal ?? 0, currency);

            if (quoteRequestDto.Addresses != null)
            {
                result.Addresses = quoteRequestDto.Addresses.Select(a => ToAddress(a)).ToList();
            }

            if (quoteRequestDto.Attachments != null)
            {
                result.Attachments = quoteRequestDto.Attachments.Select(a => ToAttachment(a)).ToList();
            }

            if (!string.IsNullOrEmpty(quoteRequestDto.Coupon))
            {
                result.Coupon = new Coupon {
                    AppliedSuccessfully = true, Code = quoteRequestDto.Coupon
                };
            }

            if (quoteRequestDto.DynamicProperties != null)
            {
                result.DynamicProperties = quoteRequestDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            if (quoteRequestDto.Items != null)
            {
                result.Items = quoteRequestDto.Items.Select(i => ToQuoteItem(i, currency)).ToList();
            }

            // TODO
            if (quoteRequestDto.ShipmentMethod != null)
            {
            }

            if (quoteRequestDto.TaxDetails != null)
            {
                result.TaxDetails = quoteRequestDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            if (quoteRequestDto.Totals != null)
            {
                result.Totals = ToQuoteTotals(quoteRequestDto.Totals, currency);
            }

            return(result);
        }
Esempio n. 3
0
        public virtual quoteDto.QuoteRequest ToQuoteRequestDto(QuoteRequest quoteRequest)
        {
            var result = new quoteDto.QuoteRequest
            {
                CancelledDate      = quoteRequest.CancelledDate,
                CancelReason       = quoteRequest.CancelReason,
                ChannelId          = quoteRequest.ChannelId,
                Comment            = quoteRequest.Comment,
                CreatedBy          = quoteRequest.CreatedBy,
                CreatedDate        = quoteRequest.CreatedDate,
                CustomerId         = quoteRequest.CustomerId,
                CustomerName       = quoteRequest.CustomerName,
                EmployeeId         = quoteRequest.EmployeeId,
                EmployeeName       = quoteRequest.EmployeeName,
                EnableNotification = quoteRequest.EnableNotification,
                ExpirationDate     = quoteRequest.ExpirationDate,
                Id               = quoteRequest.Id,
                IsAnonymous      = quoteRequest.IsAnonymous,
                IsCancelled      = quoteRequest.IsCancelled,
                IsLocked         = quoteRequest.IsLocked,
                ModifiedBy       = quoteRequest.ModifiedBy,
                ModifiedDate     = quoteRequest.ModifiedDate,
                Number           = quoteRequest.Number,
                OrganizationId   = quoteRequest.OrganizationId,
                OrganizationName = quoteRequest.OrganizationName,
                ReminderDate     = quoteRequest.ReminderDate,
                Status           = quoteRequest.Status,
                StoreId          = quoteRequest.StoreId,
                Tag              = quoteRequest.Tag,

                Currency                = quoteRequest.Currency.Code,
                Addresses               = quoteRequest.Addresses.Select(ToQuoteAddressDto).ToList(),
                Attachments             = quoteRequest.Attachments.Select(ToQuoteAttachmentDto).ToList(),
                DynamicProperties       = quoteRequest.DynamicProperties.Select(ToQuoteDynamicPropertyDto).ToList(),
                Items                   = quoteRequest.Items.Select(ToQuoteItemDto).ToList(),
                LanguageCode            = quoteRequest.Language.CultureName,
                ManualRelDiscountAmount = quoteRequest.ManualRelDiscountAmount != null ? (double?)quoteRequest.ManualRelDiscountAmount.Amount : null,
                ManualShippingTotal     = quoteRequest.ManualShippingTotal != null ? (double?)quoteRequest.ManualShippingTotal.Amount : null,
                ManualSubTotal          = quoteRequest.ManualSubTotal != null ? (double?)quoteRequest.ManualSubTotal.Amount : null,
                TaxDetails              = quoteRequest.TaxDetails.Select(ToQuoteTaxDetailDto).ToList()
            };

            if (quoteRequest.Coupon != null && quoteRequest.Coupon.AppliedSuccessfully)
            {
                result.Coupon = quoteRequest.Coupon.Code;
            }

            if (quoteRequest.Totals != null)
            {
                result.Totals = ToQuoteTotalsDto(quoteRequest.Totals);
            }

            return(result);
        }
Esempio n. 4
0
 public static QuoteRequest ToQuoteRequest(this quoteDto.QuoteRequest quoteRequestDto, Currency currency, Language language)
 {
     return(QuoteConverterInstance.ToQuoteRequest(quoteRequestDto, currency, language));
 }
Esempio n. 5
0
        public virtual QuoteRequest ToQuoteRequest(quoteDto.QuoteRequest quoteRequestDto, Currency currency, Language language)
        {
            var result = new QuoteRequest(currency, language)
            {
                CancelledDate      = quoteRequestDto.CancelledDate,
                CancelReason       = quoteRequestDto.CancelReason,
                ChannelId          = quoteRequestDto.ChannelId,
                Comment            = quoteRequestDto.Comment,
                CreatedBy          = quoteRequestDto.CreatedBy,
                CreatedDate        = quoteRequestDto.CreatedDate,
                CustomerId         = quoteRequestDto.CustomerId,
                CustomerName       = quoteRequestDto.CustomerName,
                EmployeeId         = quoteRequestDto.EmployeeId,
                EmployeeName       = quoteRequestDto.EmployeeName,
                EnableNotification = quoteRequestDto.EnableNotification ?? false,
                ExpirationDate     = quoteRequestDto.ExpirationDate,
                Id               = quoteRequestDto.Id,
                IsAnonymous      = quoteRequestDto.IsAnonymous ?? false,
                IsCancelled      = quoteRequestDto.IsCancelled ?? false,
                IsLocked         = quoteRequestDto.IsLocked ?? false,
                ModifiedBy       = quoteRequestDto.ModifiedBy,
                ModifiedDate     = quoteRequestDto.ModifiedDate,
                Number           = quoteRequestDto.Number,
                OrganizationId   = quoteRequestDto.OrganizationId,
                OrganizationName = quoteRequestDto.OrganizationName,
                ReminderDate     = quoteRequestDto.ReminderDate,
                Status           = quoteRequestDto.Status,
                StoreId          = quoteRequestDto.StoreId,
                Tag              = quoteRequestDto.Tag,

                Currency = currency,
                Language = language,
                ManualRelDiscountAmount = new Money(quoteRequestDto.ManualRelDiscountAmount ?? 0, currency),
                ManualShippingTotal     = new Money(quoteRequestDto.ManualShippingTotal ?? 0, currency),
                ManualSubTotal          = new Money(quoteRequestDto.ManualSubTotal ?? 0, currency)
            };

            if (quoteRequestDto.Addresses != null)
            {
                result.Addresses = quoteRequestDto.Addresses.Select(a => ToAddress(a)).ToList();
            }

            if (quoteRequestDto.Attachments != null)
            {
                result.Attachments = quoteRequestDto.Attachments.Select(a => ToAttachment(a)).ToList();
            }

            if (!string.IsNullOrEmpty(quoteRequestDto.Coupon))
            {
                result.Coupon = new Coupon {
                    AppliedSuccessfully = true, Code = quoteRequestDto.Coupon
                };
            }

            if (quoteRequestDto.DynamicProperties != null)
            {
                result.DynamicProperties = quoteRequestDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            if (quoteRequestDto.Items != null)
            {
                result.Items = quoteRequestDto.Items.Select(i => ToQuoteItem(i, currency)).ToList();
            }

            // TODO
            if (quoteRequestDto.ShipmentMethod != null)
            {
            }

            if (quoteRequestDto.TaxDetails != null)
            {
                result.TaxDetails = quoteRequestDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            if (quoteRequestDto.Totals != null)
            {
                result.Totals = ToQuoteTotals(quoteRequestDto.Totals, currency);
            }

            return(result);
        }
Esempio n. 6
0
 public static QuoteRequest ToQuoteRequest(this quoteDto.QuoteRequest quoteRequestDto, IEnumerable <Currency> availCurrencies, Language language)
 {
     return(QuoteConverterInstance.ToQuoteRequest(quoteRequestDto, availCurrencies, language));
 }