Example #1
0
        public int ProcessOrderToVendor(EdiOrder order, ConnectorRelation ediRelation, Configuration config)
        {
            string company      = ediRelation.EdiVendor.CompanyCode;
            string businessUnit = string.Empty;

            if (company.Contains("-"))
            {
                businessUnit = company.Split('-')[1];
                company      = company.Split('-')[0];
            }
            string dcto = ediRelation.EdiVendor.DefaultDocumentType;

            #region CreateOrder
            using (JDEDataContext context = new JDEDataContext(ConfigurationManager.ConnectionStrings["JDE"].ConnectionString))
            {
                if (order.isDropShipment.HasValue && order.isDropShipment.Value)
                {
                    #region DropShipment
                    Addresses address = new Addresses();
                    address.AdressType   = '2';
                    address.MailingName  = order.ShippedToCustomer.CustomerName;
                    address.AddressLine1 = order.ShippedToCustomer.CustomerAddressLine1;
                    address.AddressLine2 = order.ShippedToCustomer.CustomerAddressLine2;
                    address.AddressLine3 = order.ShippedToCustomer.CustomerAddressLine3;;
                    if (!string.IsNullOrEmpty(order.ShippedToCustomer.CustomerEmail))
                    {
                        address.AddressLine4 = order.ShippedToCustomer.CustomerEmail;
                    }

                    address.ZIPCode = order.ShippedToCustomer.PostCode;
                    address.City    = order.ShippedToCustomer.City;
                    if (!string.IsNullOrEmpty(order.ShippedToCustomer.Country))
                    {
                        switch (order.ShippedToCustomer.Country)
                        {
                        case "Nederland":
                        case "Nederlands":
                            address.Country = "NL";
                            break;

                        case "United Kingdom":
                            address.Country = "UK";
                            break;

                        default:
                            address.Country = order.ShippedToCustomer.Country;
                            break;
                        }
                    }
                    //else
                    // address.Country = shipToCustomer.Country;

                    address.EDICompany        = company;
                    address.EDIDocumentType   = dcto;
                    address.EDIDocumentNumber = order.EdiRequestID;
                    address.DocumentCompany   = company;
                    address.DocumentType      = dcto;
                    address.FileName          = "F47011";

                    address.TransactionOriginator = ediRelation.EdiVendor.Name;
                    address.UserID    = ediRelation.EdiVendor.Name;
                    address.ProgramID = "EDI";
                    address.Date      = JulianDate.FromDate(System.DateTime.Now).Value;
                    address.Time      = double.Parse(System.DateTime.Now.ToString("HHmmss"));

                    context.Addresses.InsertOnSubmit(address);
                    #endregion
                }

                OrderHeader header = new OrderHeader();

                header.EDICompany        = company;
                header.EDIDocumentType   = dcto;
                header.EDIDocumentNumber = order.EdiRequestID;

                header.DocumentCompany = company;
                header.DocumentType    = dcto;
                header.BusinessUnit    = businessUnit.PadLeft(12);
                header.IsProcessed     = ' ';

                header.EDIMessageType = "850";

                header.EDIOrderReference = order.EdiRequestID.ToString();

                header.CustomerReference    = JdeUtility.FilterValue(order.CustomerOrderReference, 25);
                header.EndCustomerReference = JdeUtility.FilterValue(order.WebSiteOrderNumber, 25);

                //header.SoldToNumber = (double)soldToCustomer.AddressBookNumber.Value;
                header.ShipToNumber = double.Parse(order.ShippedToCustomer.EANIdentifier);
                header.ParentNumber = 0;
                header.IsProcessed  = ' ';

                if (order.RequestDate.HasValue)
                {
                    header.RequestedDate = JulianDate.FromDate(order.RequestDate.Value).Value;
                }
                else
                {
                    header.RequestedDate = JulianDate.FromDate(DateTime.Now.AddDays(1)).Value;
                }

                header.OrderedBy    = ediRelation.EdiVendor.Name;
                header.OrderTakenBy = ediRelation.EdiVendor.OrderBy;

                header.TransactionOriginator = ediRelation.EdiVendor.Name;
                header.UserID    = ediRelation.EdiVendor.Name;
                header.ProgramID = "EDI";
                header.Date      = JulianDate.FromDate(System.DateTime.Now).Value;
                header.Time      = double.Parse(System.DateTime.Now.ToString("HHmmss"));

                if (!string.IsNullOrEmpty(order.HoldCode))
                {
                    header.EDIHoldCode = order.HoldCode;
                }

                if (order.BackOrdersAllowed.HasValue)
                {
                    if (order.BackOrdersAllowed.Value)
                    {
                        header.BackordersAllowed = 'Y';
                    }
                }

                //if (order.OrderExpireDate != null)
                //{
                //  header.EDIExpireDate = JulianDate.FromDate(ediDocument.OrderHeader.OrderExpireDate).Value;
                //}

                #region Details

                double lineNumber = 1000;

                if (!string.IsNullOrEmpty(ediRelation.FreightProduct))
                {
                    OrderRequestDetail freightdetail = new OrderRequestDetail();
                    freightdetail.ProductIdentifier = new ProductIdentifier();
                    freightdetail.ProductIdentifier.ProductNumber = ediRelation.FreightProduct;
                    freightdetail.Quantity = 1;
                    header.OrderDetails.Add(AddOrderDetail(freightdetail, header, lineNumber, context));
                    lineNumber += 1000;
                }

                if (!string.IsNullOrEmpty(ediRelation.FinChargesProduct))
                {
                    OrderRequestDetail finChargesdetail = new OrderRequestDetail();
                    finChargesdetail.ProductIdentifier = new ProductIdentifier();
                    finChargesdetail.ProductIdentifier.ProductNumber = ediRelation.FinChargesProduct;
                    finChargesdetail.Quantity = 1;
                    header.OrderDetails.Add(AddOrderDetail(finChargesdetail, header, lineNumber, context));
                    lineNumber += 1000;
                }

                foreach (EdiOrderLine detail in order.EdiOrderLines)
                {
                    OrderDetail orderDetail = AddOrderDetail(null, detail, header, lineNumber, order.PartialDelivery, context);

                    if (orderDetail != null)
                    {
                        header.OrderDetails.Add(orderDetail);
                        lineNumber += 1000;
                    }
                }

                #endregion
                context.OrderHeaders.InsertOnSubmit(header);
                context.SubmitChanges();

                return(-1);
            }
            #endregion
        }
        public InvoiceNotification GenerateInvoiceNotification(EdiOrderResponse response, IEdiProcessor processor, System.Configuration.Configuration config)
        {
            List <EdiOrderResponseLine> responseLines = response.EdiOrderResponseLines.ToList();
            EdiOrder order = response.EdiOrder;

            if (order == null)
            {
                order = processor.GetOrderInformation(response, config);
            }

            List <InvoiceOrderDetail> replyItems = new List <InvoiceOrderDetail>();

            foreach (var line in responseLines)
            {
                InvoiceOrderDetail lineItem = new InvoiceOrderDetail();
                if (line.EdiOrderLineID.HasValue)
                {
                    lineItem.ProductIdentifier = new Concentrator.Web.Objects.EDI.ProductIdentifier();
                    lineItem.ProductIdentifier.ProductNumber = line.EdiOrderLine.ProductID.HasValue ? line.EdiOrderLine.ProductID.Value.ToString() : line.EdiOrderLine.CustomerItemNumber;
                    //lineItem.ProductIdentifier.ManufacturerItemID = line.EdiOrderLine.ProductID.HasValue ? line.EdiOrderLine.Product.VendorItemNumber : string.Empty;
                    //if (line.EdiOrderLine.ProductID.HasValue && line.EdiOrderLine.Product.ProductBarcodes.Count > 0)
                    //  lineItem.ProductIdentifier.EANIdentifier = line.EdiOrderLine.Product.ProductBarcodes.FirstOrDefault().Barcode;

                    lineItem.CustomerReference = new Concentrator.Web.Objects.EDI.CustomerReference();
                    lineItem.CustomerReference.CustomerItemNumber = line.EdiOrderLine.CustomerItemNumber;
                    lineItem.CustomerReference.CustomerOrder      = line.EdiOrderLine.CustomerOrderNr;
                    lineItem.CustomerReference.CustomerOrderLine  = line.EdiOrderLine.CustomerEdiOrderLineNr;
                    lineItem.LineNumber = line.EdiOrderLineID.ToString();
                }
                else
                {
                    lineItem.ProductIdentifier = new Concentrator.Web.Objects.EDI.ProductIdentifier();
                    lineItem.ProductIdentifier.ProductNumber = line.VendorItemNumber;
                    //lineItem.ProductIdentifier.ManufacturerItemID = line.EdiOrderLine.ProductID.HasValue ? line.EdiOrderLine.Product.VendorItemNumber : string.Empty;
                    //if (line.EdiOrderLine.ProductID.HasValue && line.EdiOrderLine.Product.ProductBarcodes.Count > 0)
                    //  lineItem.ProductIdentifier.EANIdentifier = line.EdiOrderLine.Product.ProductBarcodes.FirstOrDefault().Barcode;

                    lineItem.CustomerReference = new Concentrator.Web.Objects.EDI.CustomerReference();
                    lineItem.CustomerReference.CustomerItemNumber = string.Empty;
                    lineItem.CustomerReference.CustomerOrder      = line.Remark;
                    lineItem.CustomerReference.CustomerOrderLine  = line.VendorLineNumber;
                }

                if (line.DeliveryDate.HasValue)
                {
                    lineItem.PromissedDeliveryDate = line.DeliveryDate.Value;
                }

                if (line.RequestDate.HasValue)
                {
                    lineItem.RequestedDate = line.RequestDate.Value;
                }
                else if (order.RequestDate.HasValue)
                {
                    lineItem.RequestedDate = order.RequestDate.Value;
                }

                lineItem.Quantity = new Quantity();
                lineItem.Quantity.QuantityBackordered          = line.Backordered;
                lineItem.Quantity.QuantityBackorderedSpecified = true;
                lineItem.Quantity.QuantityCancelled            = line.Cancelled;
                lineItem.Quantity.QuantityCancelledSpecified   = true;
                lineItem.Quantity.QuantityOrdered          = line.Ordered;
                lineItem.Quantity.QuantityShipped          = line.Invoiced;
                lineItem.Quantity.QuantityShippedSpecified = true;

                if (string.IsNullOrEmpty(line.EdiOrderResponse.VendorDocumentNumber))
                {
                    lineItem.StatusCode = StatusCode.Reject;
                }
                else if (line.Cancelled == line.Ordered)
                {
                    lineItem.StatusCode = StatusCode.Delete;
                }
                else if (line.Ordered != line.Shipped)
                {
                    lineItem.StatusCode = StatusCode.Change;
                }
                else
                {
                    lineItem.StatusCode = StatusCode.Accept;
                }

                if (line.VatAmount.HasValue)
                {
                    lineItem.TaxAmount = line.VatAmount.Value;
                }

                lineItem.UnitOfMeasure = InvoiceOrderDetailUnitOfMeasure.EA;
                lineItem.UnitPrice     = line.Price;

                lineItem.ShipmentInformation                     = new ShipmentInformation();
                lineItem.ShipmentInformation.CarrierCode         = line.CarrierCode;
                lineItem.ShipmentInformation.NumberOfColli       = line.NumberOfUnits.HasValue ? line.NumberOfUnits.Value.ToString() : "1";
                lineItem.ShipmentInformation.NumberOfPallet      = line.NumberOfPallets.HasValue ? line.NumberOfPallets.Value.ToString() : "0";
                lineItem.ShipmentInformation.TrackAndTraceNumber = line.TrackAndTrace;

                lineItem.ExtendedPrice          = line.Price;
                lineItem.ExtendedPriceSpecified = false;

                lineItem.InvoiceNumber = response.InvoiceDocumentNumber;
                if (!string.IsNullOrEmpty(line.SerialNumbers))
                {
                    lineItem.SerialNumbers = line.SerialNumbers.Split(';');
                }

                replyItems.Add(lineItem);
            }

            InvoiceOrderHeader header = new InvoiceOrderHeader()
            {
                BSKIdentifier          = order.ConnectorRelationID.HasValue ? order.ConnectorRelationID.Value : 0,
                CustomerOrder          = order.CustomerOrderReference,
                OrderNumber            = response.VendorDocumentNumber,
                RequestedDate          = response.ReqDeliveryDate.HasValue ? response.ReqDeliveryDate.Value : order.ReceivedDate,
                RequestedDateSpecified = response.ReqDeliveryDate.HasValue,
                WebSiteOrderNumber     = order.WebSiteOrderNumber,
            };

            header.PackingInformation = new PackingInformation();
            header.PackingInformation.PackingDateTime = response.ReceiveDate;
            header.PackingInformation.PackingNumber   = response.ShippingNumber;

            if (response.PartialDelivery.HasValue && response.PartialDelivery.Value)
            {
                header.FullfillmentCode = InvoiceOrderHeaderFullfillmentCode.Partial;
            }
            else
            {
                header.FullfillmentCode = InvoiceOrderHeaderFullfillmentCode.Complete;
            }

            if (response.ShippedToCustomer != null)
            {
                header.ShipToCustomer   = FillShipToCustomer(response.ShippedToCustomer);
                header.CustomerOverride = FillCustomerOverride(response.ShippedToCustomer);
            }
            else
            {
                header.ShipToCustomer   = FillShipToCustomer(order.ShippedToCustomer);
                header.CustomerOverride = FillCustomerOverride(order.ShippedToCustomer);
            }

            if (response.SoldToCustomer != null)
            {
                header.SoldToCustomer = FillShipToCustomer(response.SoldToCustomer);
            }
            else
            {
                header.SoldToCustomer = FillShipToCustomer(order.SoldToCustomer);
            }

            if (response.InvoiceDate.HasValue)
            {
                header.InvoiceDate = response.InvoiceDate.Value;
            }

            header.InvoiceNumber = response.InvoiceDocumentNumber;
            if (response.VatAmount.HasValue)
            {
                header.InvoiceTax = response.VatAmount.Value.ToString();
            }
            if (response.TotalExVat.HasValue)
            {
                header.InvoiceTaxableAmount = response.TotalExVat.Value.ToString();
            }
            if (response.TotalAmount.HasValue)
            {
                header.InvoiceTotalInc = response.TotalAmount.Value.ToString();
            }
            if (!string.IsNullOrEmpty(response.PaymentConditionDiscount))
            {
                header.DisountAmount = response.PaymentConditionDiscount;
            }

            InvoiceNotification invoiceNotification = new InvoiceNotification()
            {
                InvoiceOrderDetails = replyItems.ToArray(),
                InvoiceOrderHeader  = header,
                Version             = "1.0"
            };

            return(invoiceNotification);
        }
Example #3
0
        public List <Objects.Models.EDI.Order.EdiOrder> ProcessOrder(string type, string document, int?connectorID)
        {
            XDocument xdocument = XDocument.Parse(document);

            using (var unit = ServiceLocator.Current.GetInstance <IUnitOfWork>())
            {
                #region ParseXML
                var header   = xdocument.Element("WebOrderRequest").Element("WebOrderHeader");
                var details  = xdocument.Element("WebOrderRequest").Element("WebOrderDetails").Elements("WebOrderDetail");
                var customer = xdocument.Element("WebOrderRequest").Element("WebCustomer");
                var ord      = new
                {
                    OrderHeader = new
                    {
                        isDropShipment =
                            header.Element("CustomerOverride").Element("Dropshipment").Try(
                                c => bool.Parse(c.Value), false),
                        CustomerOrderReference = header.Element("CustomerOrderReference").Value,
                        EdiVersion             = header.Element("EdiVersion").Value,
                        BSKIdentifier          = header.Element("BSKIdentifier").Value,
                        WebSiteOrderNumber     = header.Element("WebSiteOrderNumber").Value,
                        PaymentTermsCode       = header.Element("PaymentTermsCode").Value,
                        PaymentInstrument      = header.Element("PaymentInstrument").Value,
                        BackOrdersAllowed      = header.Try(c => bool.Parse(c.Element("BackOrdersAllowed").Value), false),
                        RouteCode     = header.Try(c => c.Element("RouteCode").Value, string.Empty),
                        EANIdentifier =
                            header.Element("ShipToCustomer").Try(
                                c => c.Element("EanIdentifier").Value, string.Empty).Trim(),
                        HoldCode       = header.Try(c => c.Element("HoldCode").Value, string.Empty),
                        NonDropDetails = new
                        {
                            ShipToShopID =
                                header.Try(c => c.Element("ShipToShopID").Value,
                                           string.Empty)
                        }
                    },
                    Customer = new
                    {
                        Name         = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("Name").Value, string.Empty),
                        AddressLine1 = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("AddressLine1").Value, string.Empty),
                        AddressLine2 = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("AddressLine2").Value, string.Empty),
                        AddressLine3 = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("AddressLine3").Value, string.Empty),
                        HouseNumber  = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("HouseNumber").Value, string.Empty),
                        PostCode     = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("ZipCode").Value, string.Empty),
                        City         = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("City").Value, string.Empty),
                        Country      = header.Try(dc => dc.Element("CustomerOverride").Element("OrderAddress").Element("Country").Value, string.Empty),
                        Email        = header.Try(dc => dc.Element("CustomerOverride").Element("CustomerContact").Element("Email").Value, string.Empty)
                    },
                    OrderLines = (from o in details
                                  let custReference = o.Element("CustomerReference")
                                                      let product = o.Element("ProductIdentifier")
                                                                    select new
                    {
                        CustomerReference = custReference == null ? null : new
                        {
                            CustomerOrder = custReference.Try(c => c.Element("CustomerOrder").Value, string.Empty),
                            CustomerOrderLine = custReference.Try(c => c.Element("CustomerOrderLine").Value, string.Empty),
                            CustomerItemNumber = custReference.Try(c => c.Element("CustomerItemNumber").Value, string.Empty)
                        },
                        Product = product == null ? null : new
                        {
                            ID = product.Element("ProductNumber").Value,
                            EAN = product.Try(c => c.Element("EANIdentifier").Value, string.Empty),
                            ManufacturerItemID = product.Try(c => c.Element("ManufacturerItemID").Value, string.Empty),
                            Qty = o.Try(c => int.Parse(c.Element("Quantity").Value), 1),
                            VendorItemNumber = o.Try(c => c.Element("VendorItemNumber").Value, string.Empty),
                            WarehouseCode = o.Try(c => c.Element("WareHouseCode").Value, string.Empty),
                            UnitPrice = o.Try(c => double.Parse(c.Element("UnitPrice").Value) / 10000, 0),
                            PriceOverride = o.Try(c => bool.Parse(c.Element("PriceOverride").Value), false)
                        }
                    }).ToList(),
                    CustomerContactInfo = customer == null ? null : new
                    {
                        Name         = customer.Try(c => c.Element("CustomerAddress").Element("Name").Value, string.Empty),
                        AddressLine1 = customer.Try(c => c.Element("CustomerAddress").Element("AddressLine1").Value, string.Empty),
                        AddressLine2 = customer.Try(c => c.Element("CustomerAddress").Element("AddressLine2").Value, string.Empty),
                        AddressLine3 = customer.Try(c => c.Element("CustomerAddress").Element("AddressLine3").Value, string.Empty),
                        Number       = customer.Try(c => c.Element("CustomerAddress").Element("Number").Value, string.Empty),
                        ZipCode      = customer.Try(c => c.Element("CustomerAddress").Element("ZipCode").Value, string.Empty),
                        City         = customer.Try(c => c.Element("CustomerAddress").Element("City").Value, string.Empty),
                        Country      = customer.Try(c => c.Element("CustomerAddress").Element("Country").Value, string.Empty),
                        Email        = customer.Try(c => c.Element("CustomerContact").Element("Email").Value, string.Empty),
                        CompanyName  = customer.Try(c => c.Element("CustomerContact").Element("Name").Value, string.Empty),
                        CoCNumber    = customer.Try(c => c.Element("CustomerContact").Element("CoCNumber").Value, string.Empty)
                    }
                };
                #endregion

                #region Dropshipment/Non-Drop

                //Customer customerE = (from c in context.Customers
                //                      where c.EANIdentifier == ord.OrderHeader.EANIdentifier
                //                      select c).FirstOrDefault();

                //if (customerE == null ||  ord.OrderHeader.EANIdentifier == "0")
                //{
                Concentrator.Objects.Models.Orders.Customer customerE = new Concentrator.Objects.Models.Orders.Customer
                {
                    EANIdentifier = ord.OrderHeader.EANIdentifier
                };
                unit.Scope.Repository <Concentrator.Objects.Models.Orders.Customer>().Add(customerE);
                //}
                if (ord.Customer != null)
                {
                    customerE.CustomerAddressLine1 = ord.Customer.AddressLine1;
                    customerE.CustomerAddressLine2 = ord.Customer.AddressLine2;
                    customerE.CustomerAddressLine3 = ord.Customer.AddressLine3;
                    customerE.HouseNumber          = ord.Customer.HouseNumber;
                    customerE.City          = ord.Customer.City;
                    customerE.Country       = ord.Customer.Country;
                    customerE.PostCode      = ord.Customer.PostCode;
                    customerE.CustomerName  = ord.Customer.Name;
                    customerE.CustomerEmail = ord.Customer.Email;//ord.Try(c => c.CustomerContactInfo.Email, string.Empty);
                }

                Concentrator.Objects.Models.Orders.Customer customerS = null;
                if (ord.CustomerContactInfo != null)
                {
                    customerS = new Concentrator.Objects.Models.Orders.Customer
                    {
                        EANIdentifier = null
                    };
                    customerS.CustomerAddressLine1 = ord.CustomerContactInfo.AddressLine1;
                    customerS.CustomerAddressLine2 = ord.CustomerContactInfo.AddressLine2;
                    customerS.CustomerAddressLine3 = ord.CustomerContactInfo.AddressLine3;
                    customerS.HouseNumber          = ord.CustomerContactInfo.Number;
                    customerS.City          = ord.CustomerContactInfo.City;
                    customerS.Country       = ord.CustomerContactInfo.Country;
                    customerS.PostCode      = ord.CustomerContactInfo.ZipCode;
                    customerS.CustomerName  = ord.CustomerContactInfo.Name;
                    customerS.CustomerEmail = ord.CustomerContactInfo.Email;
                    customerS.CoCNumber     = ord.CustomerContactInfo.CoCNumber;

                    unit.Scope.Repository <Concentrator.Objects.Models.Orders.Customer>().Add(customerS);
                }

                if (!connectorID.HasValue)
                {
                    ConnectorRelation rel = unit.Scope.Repository <ConnectorRelation>().GetSingle(x => x.CustomerID == customerE.EANIdentifier);

                    if (rel == null || !rel.ConnectorID.HasValue)
                    {
                        throw new Exception("No Connector Relation found for numer" + customerE.EANIdentifier);
                    }
                    else
                    {
                        connectorID = rel.ConnectorID.Value;
                    }
                }

                EdiOrder newOrd = new EdiOrder()
                {
                    ShippedToCustomer      = customerE,
                    SoldToCustomer         = customerS,
                    Document               = document,
                    ConnectorID            = connectorID.Value,
                    isDropShipment         = ord.OrderHeader.isDropShipment,
                    ReceivedDate           = DateTime.Now,
                    BackOrdersAllowed      = ord.OrderHeader.BackOrdersAllowed,
                    CustomerOrderReference = ord.OrderHeader.CustomerOrderReference,
                    EdiVersion             = ord.OrderHeader.EdiVersion,
                    BSKIdentifier          = int.Parse(ord.OrderHeader.BSKIdentifier),
                    WebSiteOrderNumber     = ord.OrderHeader.WebSiteOrderNumber,
                    PaymentInstrument      = ord.OrderHeader.PaymentInstrument,
                    PaymentTermsCode       = ord.OrderHeader.PaymentTermsCode,
                    RouteCode              = ord.OrderHeader.RouteCode,
                    HoldCode               = ord.OrderHeader.HoldCode
                };
                #endregion
                var orderRepo      = unit.Scope.Repository <EdiOrder>();
                var duplicateOrder = orderRepo.GetSingle(d => d.ConnectorID == newOrd.ConnectorID &&
                                                         d.WebSiteOrderNumber == newOrd.WebSiteOrderNumber);


                if (duplicateOrder != null)
                {
                    newOrd.HoldOrder = true;
                }
                else
                {
                    newOrd.HoldOrder = false;
                }

                orderRepo.Add(newOrd);

                #region Order Lines
                foreach (var line in ord.OrderLines)
                {
                    int?productid = null;
                    var product   = unit.Scope.Repository <Concentrator.Objects.Models.Products.Product>().GetSingle(p => p.ProductID == int.Parse(line.Product.ID));

                    if (product != null)
                    {
                        productid = product.ProductID;
                    }

                    EdiOrderLine ol = new EdiOrderLine
                    {
                        CustomerEdiOrderLineNr = line.CustomerReference.CustomerOrderLine,
                        CustomerOrderNr        = line.CustomerReference.CustomerOrder,
                        CustomerItemNumber     = line.CustomerReference.CustomerItemNumber,
                        EdiOrder      = newOrd,
                        Quantity      = line.Product.Qty,
                        ProductID     = productid,
                        Price         = line.Product.UnitPrice,
                        WareHouseCode = line.Product.WarehouseCode,
                        PriceOverride = line.Product.PriceOverride,
                        EdiProductID  = line.Product.ID
                    };

                    unit.Scope.Repository <EdiOrderLine>().Add(ol);
                }
                #endregion

                unit.Save();

                return(new List <EdiOrder>()
                {
                    newOrd
                });
            }
        }