public TemplateControlCollection GetControls(int templateId, int documentId, int documentTypeId) { var command = SqlDbAccess.CreateTextCommand(); command.CommandText = @" SELECT TC.TemplateControlId, TC.FriendlyName, IsNull(TCC.Content, TC.Content) AS Content, TC.Content AS DefaultContent, TC.VisualProperties, TC.CreationGUID, TC.Class, CP.Name as ControlName, CP.ControlType, CP.Category FROM [Cerberus.TemplateEngine.TemplateControl] TC JOIN [Cerberus.TemplateEngine.ControlPlugin] CP ON TC.ControlPluginId = CP.ControlPluginId LEFT JOIN [Cerberus.TemplateEngine.TemplateControlContent] TCC ON TCC.TemplateControlId = TC.TemplateControlId AND TCC.DocumentId=@DocumentId AND TCC.DocumentTypeId=@DocumentTypeId WHERE TemplateId = @TemplateId" ; SqlDbAccess.AddParameter(command, "@TemplateId", SqlDbType.Int, templateId); SqlDbAccess.AddParameter(command, "@DocumentId", SqlDbType.Int, documentId); SqlDbAccess.AddParameter(command, "@DocumentTypeId", SqlDbType.Int, documentTypeId); return(TemplateControlCollection.CreateFromData(SqlDbAccess.ExecuteSelect(command))); }
public void RemoveTemplateControlsNotInCollection(int templateId, IEnumerable <int> templateControlIds) { var templateControlIdsAsString = templateControlIds.Count() > 0 ? string.Join(",", templateControlIds) : "-1"; var command = SqlDbAccess.CreateTextCommand(); command.CommandText = string.Format(@" DELETE FROM [Cerberus.TemplateEngine.TemplateControl] WHERE TemplateId = @TemplateId AND TemplateControlId NOT IN ({0})" , templateControlIdsAsString); SqlDbAccess.AddParameter(command, "@TemplateId", SqlDbType.Int, templateId); SqlDbAccess.ExecuteSelect(command); }
public Template GetTemplate(int templateId) { var command = SqlDbAccess.CreateTextCommand(); command.CommandText = @" SELECT TemplateId, Name, CreatedByUserId, CreatedDate, LastModifiedDate, VisualProperties FROM [Cerberus.TemplateEngine.Template] WHERE TemplateId = @TemplateId" ; SqlDbAccess.AddParameter(command, "@TemplateId", SqlDbType.Int, templateId); return(Template.CreateFromData(SqlDbAccess.ExecuteSelect(command).Rows[0])); }
public ResolutionCollection GetResolutions(int templateId) { var command = SqlDbAccess.CreateTextCommand(); command.CommandText = @" SELECT R.ResolutionId, R.Width, TCR.TemplateControlId, TCR.VisualProperties FROM [Cerberus.TemplateEngine.Resolution] R LEFT JOIN [Cerberus.TemplateEngine.TemplateControlResolution] TCR ON R.ResolutionId=TCR.ResolutionId WHERE R.TemplateId = @TemplateId ORDER BY R.Width ASC" ; SqlDbAccess.AddParameter(command, "@TemplateId", SqlDbType.Int, templateId); return(ResolutionCollection.CreateFromData(SqlDbAccess.ExecuteSelect(command))); }
public TemplateCollection GetTemplates(TemplateSearchParameters searchParameters) { var command = SqlDbAccess.CreateTextCommand(); var sb = new StringBuilder(@" SELECT TemplateId, Name, CreatedByUserId, CreatedDate, LastModifiedDate, VisualProperties FROM [Cerberus.TemplateEngine.Template] " ); if (searchParameters.CreatedByUserId > 0) { sb.AppendLine(" WHERE CreatedByUserId = @CreatedByUserId "); SqlDbAccess.AddParameter(command, "@CreatedByUserId", SqlDbType.Int, searchParameters.CreatedByUserId); } command.CommandText = sb.ToString(); return(TemplateCollection.CreateDataObjectCollection(SqlDbAccess.ExecuteSelect(command))); }