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

            var proposalsParameter = new CL5_APOProcurement_Proposals.Atomic.Retrieval.P_L5PR_GRPCfHL_1418();
            proposalsParameter.HeaderID_List = Parameter.ProposalsHeaders;

            var proposals = CL5_APOProcurement_Proposals.Atomic.Retrieval.cls_Get_RequestProposals_Customer_for_HeaderIdList
                            .Invoke(Connection, Transaction, proposalsParameter, securityTicket).Result.ToList();

            List <Guid> articlesList = new List <Guid>();
            foreach (var proposal in proposals)
            {
                articlesList.Add(proposal.CMN_PRO_Product_RefID);
            }

            var articlesParameter = new CL3_Articles.Atomic.Retrieval.P_L3AR_GAfAL_0942();
            articlesParameter.ProductID_List = articlesList.ToArray();

            var articles = new List <CL3_Articles.Atomic.Retrieval.L3AR_GAfAL_0942>();

            if (articlesList.Count > 0)
            {
                articles = CL3_Articles.Atomic.Retrieval.cls_Get_Articles_for_ArticleList.
                           Invoke(Connection, Transaction, articlesParameter, securityTicket).Result.ToList();
            }

            List <L5PR_GRPwADfHIDL_1413a> proposalsWithDetails = new List <L5PR_GRPwADfHIDL_1413a>();

            foreach (var proposal in proposals)
            {
                L5PR_GRPwADfHIDL_1413a tempProposalWithDetails = new L5PR_GRPwADfHIDL_1413a();
                tempProposalWithDetails.Proposal = proposal;
                tempProposalWithDetails.Article  = articles.Where(ar => ar.CMN_PRO_ProductID == proposal.CMN_PRO_Product_RefID).Single();
                proposalsWithDetails.Add(tempProposalWithDetails);
            }

            returnValue.Result = new L5PR_GRPwADfHIDL_1413();
            returnValue.Result.ProposalsWithArticleDetails = proposalsWithDetails.ToArray();

            return(returnValue);

            #endregion UserCode
        }
Example #2
0
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_L5PR_GRPwADfHIDL_1413 Invoke(DbConnection Connection, P_L5PR_GRPwADfHIDL_1413 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
Example #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5PR_GRPwADfHIDL_1413 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5PR_GRPwADfHIDL_1413 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5PR_GRPwADfHIDL_1413 functionReturn = new FR_L5PR_GRPwADfHIDL_1413();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Get_RequestProposals_with_ArticleDetails_for_HeaderIDList", ex);
            }
            return(functionReturn);
        }