private void Configure(ConverterConfigurator <FirstContractDocument, InnerDocument> configurator) { configurator.Target(x => x.FromGln).Set(x => x.Header.Sender); configurator.Target(x => x.ToGln).Set(x => x.Header.Recipient); configurator.Target(x => x.IsTest).Set(x => x.Header.IsTest == "1"); configurator.Target(x => x.CreationDateTimeBySender).Set(x => x.Header.CreationDateTime ?? x.CreationDateTime); var subConfigurator = configurator.GoTo(x => x, x => x.Document[0]); subConfigurator.Target(x => x.OrdersNumber).Set(x => x.OriginOrder.Number); subConfigurator.Target(x => x.OrdersDate).Set(x => x.OriginOrder.Date); subConfigurator.Target(x => x.DeliveryType).Set(x => x.DeliveryType.ParseNullableEnum <DocumentsDeliveryType>()); subConfigurator.Target(x => x.TransportBy).Set(x => x.DeliveryInfo.TransportBy, x => defaultConverter.Convert(x)); subConfigurator.Target(x => x.SumTotal).Set(x => decimalConverter.ToDecimal(x.LineItems.TotalSumExcludingTaxes)); subConfigurator.Target(x => x.RecadvType) .If(x => !string.IsNullOrEmpty(x.Status) && x.Status.Contains("canceled")) .Set(x => TypeOfDocument.Canceled); subConfigurator.Target(x => x.FlowType).Set(x => x.Comment == "Fresh" ? "fresh" : defaultConverter.Convert(x.LineItems.LineItem.FirstOrDefault().FlowType)); subConfigurator.Target(x => x.IntervalLength).Set(x => x.IntervalLength.ParseNullableInt()); PartyInfoConfigurators.ConfigureFromFirstContractToInner(subConfigurator.GoTo(x => x.Buyer, x => x.Buyer), defaultConverter); PartyInfoConfigurators.ConfigureFromFirstContractToInner(subConfigurator.GoTo(x => x.Supplier, x => x.Seller), defaultConverter); ConfigureGoodItems(subConfigurator.GoTo(x => x.GoodItems.Each(), x => x.LineItems.LineItem.Current())); subConfigurator.Target(x => x.MessageCodes.Each()).Set(x => x.MessageCodes.Current()); subConfigurator.Target(x => x.Nullify).Set(x => x.MessageCodes[0] == "nullify"); subConfigurator.Target(x => x.MessageCodes[1]).NullifyIf(x => x.Nullify); }
private void Configure(ConverterConfigurator <InnerDocument, FirstContractDocument> configurator) { configurator.Target(x => x.CreationDateTime).Set(x => UtcNow()); var headerConfigurator = configurator.GoTo(x => x.Header, x => x); headerConfigurator.Target(x => x.Sender).Set(x => x.FromGln); headerConfigurator.Target(x => x.Recipient).Set(x => x.ToGln); headerConfigurator.Target(x => x.IsTest).Set(x => x.IsTest ? "1" : null); headerConfigurator.Target(x => x.CreationDateTime).Set(x => DateTime.UtcNow); var subConfigurator = configurator.GoTo(x => x.Document[0], x => x); subConfigurator.Target(x => x.Comment).Set(x => Guid.NewGuid().ToString()); subConfigurator.Target(x => x.MessageCodes[0]).Set(x => NewGuid().ToString()); subConfigurator.Target(x => x.OriginOrder.Number).Set(x => x.OrdersNumber); subConfigurator.Target(x => x.OriginOrder.Date).Set(x => x.OrdersDate); subConfigurator.Target(x => x.DeliveryType).Set(x => x.DeliveryType.Value.ToString()); subConfigurator.Target(x => x.DeliveryInfo.TransportBy).Set(x => defaultConverter.Convert(x.TransportBy)); subConfigurator.Target(x => x.LineItems.TotalSumExcludingTaxes).Set(x => decimalConverter.ToString(x.SumTotal)); subConfigurator.Target(x => x.Status) .If(x => x.RecadvType.GetValueOrDefault(TypeOfDocument.Original) == TypeOfDocument.Canceled) .Set(x => "canceled"); subConfigurator.Target(x => x.IntervalLength).Set(x => x.IntervalLength.Value.ToString()); PartyInfoConfigurators.ConfigureFromInnerToFirstContract(subConfigurator.GoTo(x => x.Buyer, x => x.Buyer), defaultConverter); PartyInfoConfigurators.ConfigureFromInnerToFirstContract(subConfigurator.GoTo(x => x.Seller, x => x.Supplier), defaultConverter); ConfigureGoodItems(subConfigurator.GoTo(x => x.LineItems.LineItem.Each(), x => x.GoodItems.Current())); }