예제 #1
0
        public async Task <ActionResult> GetById([FromQuery] PageTemplateQueryParams query)
        {
            var template = await pageTemplateService.GetPageTemplate(query.TemplateId);

            if (template == null)
            {
                return(NotFound(new { Message = "Display template for page not found" }));
            }
            return(Ok(template));
        }
        public void GetPageTemplate_Exists()
        {
            var id       = "templateId";
            var testHtml = "<span>{{ context.testing }}</span>";
            var testCss  = "span { color: red }";

            using (var db = TestHarness.GetPortalContext())
            {
                db.PageTemplates.Add(new Models.PageTemplate
                {
                    Id   = id,
                    Html = testHtml,
                    Css  = testCss
                });
                db.SaveChanges();
            }

            var pageTemplate = service.GetPageTemplate(id).GetAwaiter().GetResult();

            Assert.IsNotNull(pageTemplate, "page template should be found");
            Assert.AreEqual(id, pageTemplate.Id);
            Assert.AreEqual(testHtml, pageTemplate.Html);
            Assert.AreEqual(testCss, pageTemplate.Css);
        }