Exemplo n.º 1
0
 public static int Add(XSLTemplate xslTemplate)
 {
     return XSLTemplateDataMapper.Add(xslTemplate);
 }
Exemplo n.º 2
0
 public static void Update(XSLTemplate xslTemplate)
 {
     XSLTemplateDataMapper.Update(xslTemplate);
 }
        internal static XSLTemplate GetXSLTemplate(List<XSLTemplate> xslTemplates, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_ID);
            int value = reader.GetInt32(colIndex);

            XSLTemplate xslTemplate = xslTemplates.Where(c => c.ID == value).FirstOrDefault();
            if (xslTemplate == null)
            {
                xslTemplate = new XSLTemplate();
                xslTemplates.Add(xslTemplate);
            }
            return xslTemplate;
        }
        internal static void FillFromReader(XSLTemplate xslTemplate, SqlDataReader reader)
        {
            int colIndex = 0;

            int days = 0, seconds = 0;
            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_CREATION_DAY);
            if (!reader.IsDBNull(colIndex))
                days = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_CREATION_SEC);
            if (!reader.IsDBNull(colIndex))
                seconds = reader.GetInt32(colIndex);

            xslTemplate.CreationDate = CMSCoreHelper.GetDateTime(days, seconds);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_DESCRIPTION);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.Description = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_DETAILS);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.Details = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_ID);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_IS_DELETED);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.IsDeleted = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_LANGUAGE_ID);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.LanguageID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_MODULE_ID);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.ModuleID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_NAME);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.Name = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_PORTAL_ID);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.PortalID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_XSLTEMPLATE_CREATED_BY);
            if (!reader.IsDBNull(colIndex))
                xslTemplate.CreatedBy = reader.GetInt32(colIndex);
        }
        internal static XSLTemplate GetXSLTemplateById(int XSLTemplateID)
        {
            XSLTemplate xslTemplate = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_XSLTEMPLATE_GET_BY_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter parameter = new SqlParameter(PN_XSLTEMPLATE_ID, System.Data.SqlDbType.Int);
                parameter.Direction = System.Data.ParameterDirection.Input;
                parameter.Value = XSLTemplateID;
                sqlCommand.Parameters.Add(parameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    while (reader.Read())
                    {
                        if (xslTemplate == null)
                            xslTemplate = new XSLTemplate();
                        FillFromReader(xslTemplate, reader);
                    }
                    reader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return xslTemplate;
        }