Inheritance: IEntity
コード例 #1
0
 public static int Add(Template template)
 {
     return TemplateDataMapper.Add(template);
 }
コード例 #2
0
 public static void Update(Template template)
 {
     TemplateDataMapper.Update(template);
 }
コード例 #3
0
        internal static Template GetTemplate(List<Template> templates, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_TEMPLATE_ID);
            int value = reader.GetInt32(colIndex);

            Template template = templates.Where(c => c.ID == value).FirstOrDefault();
            if (template == null)
            {
                template = new Template();
                templates.Add(template);
            }
            return template;
        }
コード例 #4
0
        internal static void FillFromReader(Template template, SqlDataReader reader)
        {
            int colIndex = 0;

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

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

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

            colIndex = reader.GetOrdinal(CN_TEMPLATE_DESCRIPTION);
            if (!reader.IsDBNull(colIndex))
                template.Description = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_DETAILS);
            if (!reader.IsDBNull(colIndex))
                template.Details = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_ID);
            if (!reader.IsDBNull(colIndex))
                template.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_IMAGE);
            if (!reader.IsDBNull(colIndex))
                template.Image = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_IS_DELETED);
            if (!reader.IsDBNull(colIndex))
                template.IsDeleted = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_LANGUAGE_ID);
            if (!reader.IsDBNull(colIndex))
                template.LanguageID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_NAME);
            if (!reader.IsDBNull(colIndex))
                template.Name = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_PORTAL_ID);
            if (!reader.IsDBNull(colIndex))
                template.PortalID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_TEMPLATE_CREATED_BY);
            if (!reader.IsDBNull(colIndex))
                template.CreatedBy = reader.GetInt32(colIndex);
        }
コード例 #5
0
        internal static Template GetTemplate(int TemplateID)
        {
            Template template = null;

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

                SqlParameter sqlParameter = new SqlParameter(PN_TEMPLATE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = TemplateID;
                sqlCommand.Parameters.Add(sqlParameter);

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