protected ShortCustomReportTemplateViewData(CustomReportTemplate template)
 {
     Id        = template.Id;
     Name      = template.Name;
     Type      = template.Type;
     HeaderId  = template.HeaderRef;
     FooterId  = template.FooterRef;
     HasHeader = template.HeaderRef.HasValue;
     HasFooter = template.FooterRef.HasValue;
 }
 protected CustomReportTemplateViewData(CustomReportTemplate template) : base(template)
 {
     Layout = template.Layout;
     Style  = template.Style;
     if (template.Header != null)
     {
         Header = Create(template.Header);
     }
     if (template.Footer != null)
     {
         Footer = Create(template.Footer);
     }
 }
        public CustomReportTemplate Edit(Guid templateId, string name, string layout, string style, byte[] icon, Guid?headerId, Guid?footerId, TemplateType type)
        {
            BaseSecurity.EnsureSysAdmin(Context);
            CustomReportTemplate template = null;

            DoUpdate(u =>
            {
                var da             = new DataAccessBase <CustomReportTemplate, Guid>(u);
                template           = da.GetById(templateId);
                template.Layout    = layout;
                template.Style     = style;
                template.Name      = name;
                template.FooterRef = footerId;
                template.HeaderRef = headerId;
                template.Type      = (int)type;
                da.Update(template);
                if (icon != null)
                {
                    ServiceLocator.CustomReportTemplateIconService.UploadPicture(templateId, icon);
                }
            });
            return(template);
        }
        public CustomReportTemplate Add(string name, string layout, string style, byte[] icon, Guid?headerId, Guid?footerId, TemplateType type)
        {
            BaseSecurity.EnsureSysAdmin(Context);
            var template = new CustomReportTemplate
            {
                Id        = Guid.NewGuid(),
                Name      = name,
                Layout    = layout,
                Style     = style,
                HeaderRef = headerId,
                FooterRef = footerId,
                Type      = (int)type
            };

            DoUpdate(u =>
            {
                new DataAccessBase <CustomReportTemplate, Guid>(u).Insert(template);
                if (icon != null)
                {
                    ServiceLocator.CustomReportTemplateIconService.UploadPicture(template.Id, icon);
                }
            });
            return(template);
        }
 public static CustomReportTemplateViewData Create(CustomReportTemplate template)
 {
     return(new CustomReportTemplateViewData(template));
 }