protected static FR_L6SH_GMDfPH_0500_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L6SH_GMDfPH_0500 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6SH_GMDfPH_0500_Array();
            //Put your code here

            var supplier = cls_Get_Suppliers_for_PrivateSubscribedCatalogs.Invoke(Connection, Transaction, securityTicket).Result.FirstOrDefault();

            #region Get All OrganizationalUnits

            //TODO: This is quick and dirty solution, remove it as soon as SLorenz remove MaveFile

            var organizationalUnits = ORM_CMN_BPT_CTM_OrganizationalUnit.Query.Search(Connection, Transaction, new ORM_CMN_BPT_CTM_OrganizationalUnit.Query()
            {
                Tenant_RefID = Guid.Parse(supplier.TenantITL)
            });

            #endregion

            var paramShoppingProducts = new P_L5PO_GPPaSCIfH_1750();
            paramShoppingProducts.ProcurementOrderHeaderID = Parameter.ProcurementHeaderID;
            var shoppingCartProcurementPositions = cls_Get_ProcurementPositions_and_ShoppingCartInfo_for_HeaderID.Invoke(Connection, Transaction, paramShoppingProducts, securityTicket)
                                                   .Result.OrderBy(x => x.ORD_PRC_ShoppingCart_RefID);

            var maveResults = new List <L6SH_GMDfPH_0500>();

            var procurementHeader = new ORM_ORD_PRC_ProcurementOrder_Header();
            procurementHeader.Load(Connection, Transaction, Parameter.ProcurementHeaderID);

            var previousShoppingCartID = Guid.Empty;
            var currentShoppingCart    = new ORM_ORD_PRC_ShoppingCart();

            var accountsForTenant = cls_Get_AllDisplayNames_of_Accounts_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result;

            foreach (var shoppingCartProcurementPosition in shoppingCartProcurementPositions)
            {
                var maveResult = new L6SH_GMDfPH_0500();

                var currentProduct = new ORM_CMN_PRO_Product();
                currentProduct.Load(Connection, Transaction, shoppingCartProcurementPosition.CMN_PRO_Product_RefID);

                if (currentShoppingCart.ORD_PRC_ShoppingCartID == Guid.Empty || shoppingCartProcurementPosition.ORD_PRC_ShoppingCart_RefID != previousShoppingCartID)
                {
                    currentShoppingCart.Load(Connection, Transaction, shoppingCartProcurementPosition.ORD_PRC_ShoppingCart_RefID);
                }

                var userThatApproved = accountsForTenant.FirstOrDefault(x => x.USR_AccountID == currentShoppingCart.CreatedBy_Account_RefID);

                #region Add ShoppingCart Position

                //TODO: This is quick and dirty solution, remove it as soon as SLorenz remove MaveFile
                var organizationalUnit = organizationalUnits.Where(i => i.CustomerTenant_OfficeITL == shoppingCartProcurementPosition.CMN_STR_OfficeID.ToString()).Single();

                maveResult.CustomerNumber             = supplier.ExternalSupplierProvidedIdentifier;
                maveResult.OrgUnitNumber              = organizationalUnit.InternalOrganizationalUnitNumber;
                maveResult.OrderDateTime              = procurementHeader.ProcurementOrder_Date;
                maveResult.PriceOfAllPositionsOverAll = procurementHeader.TotalValue_BeforeTax;
                maveResult.PZNorTXT             = currentProduct.Product_Number;
                maveResult.UserThatApproved     = userThatApproved.DisplayName;
                maveResult.OrderQuantity        = Convert.ToInt32(shoppingCartProcurementPosition.Position_Quantity);
                maveResult.PositionPricePerUnit = shoppingCartProcurementPosition.Position_ValuePerUnit;
                maveResult.Comment          = string.Empty;
                maveResult.IncreasingNumber = "108384";

                maveResults.Add(maveResult);
                #endregion

                #region Add ShoppingCart Comment
                // get all comments for current shopping chart and do that just once!
                if (currentShoppingCart.ORD_PRC_ShoppingCartID != previousShoppingCartID)
                {
                    previousShoppingCartID = currentShoppingCart.ORD_PRC_ShoppingCartID;

                    var shoppingNoteParameter = new P_L5AWSAR_GSCNfSC_1454();
                    shoppingNoteParameter.ShoppingCartID = currentShoppingCart.ORD_PRC_ShoppingCartID;
                    var shoppingCartNotes = cls_Get_ShoppingCart_Notes_for_ShoppingCartID.Invoke(Connection, Transaction, shoppingNoteParameter, securityTicket).Result;

                    foreach (var note in shoppingCartNotes)
                    {
                        if (!note.IsNoteForProcurementOrder)
                        {
                            continue;
                        }

                        maveResult = new L6SH_GMDfPH_0500();

                        maveResult.CustomerNumber             = supplier.ExternalSupplierProvidedIdentifier;
                        maveResult.OrgUnitNumber              = organizationalUnit.InternalOrganizationalUnitNumber;
                        maveResult.OrderDateTime              = procurementHeader.ProcurementOrder_Date;
                        maveResult.PriceOfAllPositionsOverAll = procurementHeader.TotalValue_BeforeTax;
                        maveResult.PZNorTXT             = "TEXT";
                        maveResult.UserThatApproved     = userThatApproved.DisplayName;
                        maveResult.OrderQuantity        = 0;
                        maveResult.PositionPricePerUnit = 0;
                        maveResult.Comment          = note.Memo_Text;
                        maveResult.IncreasingNumber = "108384";

                        maveResults.Add(maveResult);
                    }
                }

                #endregion
            }


            returnValue.Result = maveResults.ToArray();
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_L6PO_GPfCOCM_1502 Execute(DbConnection Connection, DbTransaction Transaction, P_L6PO_GPfCOCM_1502 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6PO_GPfCOCM_1502();
            returnValue.Result = new L6PO_GPfCOCM_1502();

            #region Get Languages

            P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530();
            langParam.Tenant_RefID = securityTicket.TenantID;
            var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result;

            var LanguageID = DBLanguages.Where(i => i.ISO_639_1 == "DE").SingleOrDefault().CMN_LanguageID;

            #endregion

            #region ORM_ORD_PRC_ProcurementOrder_Header

            var procurementHeader = new ORM_ORD_PRC_ProcurementOrder_Header();
            procurementHeader.Load(Connection, Transaction, Parameter.ProcurementHeaderID);

            #endregion

            #region ORM_ORD_PRC_ProcurementOrder_Positions

            var paramShoppingProducts = new P_L5PO_GPPaSCIfH_1750();
            paramShoppingProducts.ProcurementOrderHeaderID = Parameter.ProcurementHeaderID;
            var shoppingProducts = cls_Get_ProcurementPositions_and_ShoppingCartInfo_for_HeaderID.Invoke(Connection, Transaction, paramShoppingProducts, securityTicket).Result;

            #endregion

            #region Positions

            var positions = new List <L6PO_GPfCOCM_1502a>();

            foreach (var shoppingProduct in shoppingProducts)
            {
                var product = new ORM_CMN_PRO_Product();
                product.Load(Connection, Transaction, shoppingProduct.CMN_PRO_Product_RefID);

                if (String.IsNullOrEmpty(product.ProductITL))
                {
                    product.ProductITL = Guid.NewGuid().ToString();
                    product.Save(Connection, Transaction);
                }

                var catalogSubscription = new ORM_CMN_PRO_SubscribedCatalog();
                catalogSubscription.Load(Connection, Transaction, product.IfImportedFromExternalCatalog_CatalogSubscription_RefID);

                var position = new L6PO_GPfCOCM_1502a();
                position.ProductITL                  = product.ProductITL;
                position.ProductNumber               = product.Product_Number;
                position.ProductName                 = product.Product_Name.GetContent(LanguageID);
                position.ProductDescription          = product.Product_Description.GetContent(LanguageID);
                position.Comment                     = "NotDefinedBySender";
                position.Quantity                    = shoppingProduct.Position_Quantity;
                position.IsProductReplacementAllowed = shoppingProduct.IsProductReplacementAllowed;
                position.SourceCatalogITL            = catalogSubscription.CatalogCodeITL;
                position.UnitPrice                   = shoppingProduct.Position_ValuePerUnit;
                position.NetoPrice                   = shoppingProduct.Position_ValueTotal;

                var shoppingCart2Office = ORM_ORD_PRC_Office_ShoppingCart.Query.Search(Connection, Transaction,
                                                                                       new ORM_ORD_PRC_Office_ShoppingCart.Query {
                    ORD_PRC_ShoppingCart_RefID = shoppingProduct.ORD_PRC_ShoppingCart_RefID,
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID
                }
                                                                                       ).Single();

                position.Quantites = new L6PO_GPfCOCM_1502b[] {
                    new L6PO_GPfCOCM_1502b()
                    {
                        OfficeID = shoppingCart2Office.CMN_STR_Office_RefID,
                        Quantity = shoppingProduct.Position_Quantity
                    }
                };

                positions.Add(position);
            }

            #endregion

            #region Comments

            var procurmentNotes = ORM_ORD_PRC_ProcurementOrder_Note.Query.Search(Connection, Transaction, new ORM_ORD_PRC_ProcurementOrder_Note.Query()
            {
                ORD_PRC_ProcurementOrder_Header_RefID = procurementHeader.ORD_PRC_ProcurementOrder_HeaderID,
                IsDeleted = false
            }).ToList();

            var comments = new List <L6PO_GPfCOCM_1502c>();

            foreach (var note in procurmentNotes)
            {
                comments.Add(
                    new L6PO_GPfCOCM_1502c()
                {
                    OfficeID       = note.CMN_STR_Office_RefID,
                    Content        = note.Comment,
                    PublilshDate   = note.NotePublishDate,
                    SequenceNumber = note.SequenceOrderNumber,
                    Title          = note.Title
                }
                    );
            }

            #endregion

            returnValue.Result.ProcurProcurementHeaderID = procurementHeader.ORD_PRC_ProcurementOrder_HeaderID;
            returnValue.Result.OrderNumber          = procurementHeader.ProcurementOrder_Number;
            returnValue.Result.ProcurementOrderDate = procurementHeader.ProcurementOrder_Date;
            returnValue.Result.Comments             = comments.ToArray();

            returnValue.Result.Positions = positions.ToArray();

            return(returnValue);

            #endregion UserCode
        }