Profiles.Edit.Utilities.DataIO.StoreEducationalTrainingReceipt C# (CSharp) Méthode

StoreEducationalTrainingReceipt() private méthode

private StoreEducationalTrainingReceipt ( EducationalTrainingRequest eatr ) : bool
eatr EducationalTrainingRequest
Résultat bool
        private bool StoreEducationalTrainingReceipt(EducationalTrainingRequest eatr)
        {
            SessionManagement sm = new SessionManagement();
            string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

            SqlConnection dbconnection = new SqlConnection(connstr);

            SqlParameter[] param = new SqlParameter[eatr.Length];

            bool error = false;

            try
            {
                dbconnection.Open();

                if (eatr.ExistingEducationalTrainingURI != null)
                    param[eatr.ExistingEducationalTrainingURI.ParamOrdinal] = new SqlParameter("@ExistingEducationalTrainingURI", eatr.ExistingEducationalTrainingURI.Value);

                if (eatr.EducationalTrainingForID != null)
                    param[eatr.EducationalTrainingForID.ParamOrdinal] = new SqlParameter("@educationalTrainingForID", Convert.ToInt64(eatr.EducationalTrainingForID.Value));

                if (eatr.Institution != null)
                    param[eatr.Institution.ParamOrdinal] = new SqlParameter("@institution", eatr.Institution.Value.ToString());

                if (eatr.Location != null)
                    param[eatr.Location.ParamOrdinal] = new SqlParameter("@location", eatr.Location.Value.ToString());

                if (eatr.Degree != null)
                    param[eatr.Degree.ParamOrdinal] = new SqlParameter("@degree", eatr.Degree.Value.ToString());

                if (eatr.EndDate != null)
                    param[eatr.EndDate.ParamOrdinal] = new SqlParameter("@endDate", eatr.EndDate.Value.ToString());

                if (eatr.FieldOfStudy != null)
                    param[eatr.FieldOfStudy.ParamOrdinal] = new SqlParameter("@fieldOfStudy", eatr.FieldOfStudy.Value.ToString());

                param[eatr.Length - 3] = new SqlParameter("@sessionID", sm.Session().SessionID);

                param[eatr.Length - 2] = new SqlParameter("@error", null);
                param[eatr.Length - 2].DbType = DbType.Boolean;
                param[eatr.Length - 2].Direction = ParameterDirection.Output;

                param[eatr.Length - 1] = new SqlParameter("@nodeid", null);
                param[eatr.Length - 1].DbType = DbType.Int64;
                param[eatr.Length - 1].Direction = ParameterDirection.Output;

                // TODO
                SqlCommand comm = GetDBCommand(ref dbconnection, "[Edit.Module].[CustomEditEducationalTraining.StoreItem]", CommandType.StoredProcedure, CommandBehavior.CloseConnection, param);
                //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value.
                ExecuteSQLDataCommand(comm);

                comm.Connection.Close();

                if (dbconnection.State != ConnectionState.Closed)
                    dbconnection.Close();

                error = Convert.ToBoolean(param[eatr.Length - 2].Value);

                Framework.Utilities.Cache.AlterDependency(eatr.EducationalTrainingForID.Value.ToString());
            }
            catch (Exception e)
            {
                Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace);
                throw new Exception(e.Message);
            }

            return error;
        }