public void CanLinkTemplate() { using (TestSession test = CreateSession()) { //test.AddActor("*****@*****.**"); WorkspaceService topoman = test.GetTopologyManager(); Workspace topo = topoman.Create(new NewWorkspace { Name = "jamTopo" }).Result; TemplateService mgr = test.GetTemplateManager(); for (int i = 1; i < 6; i++) { TemplateDetail template = mgr.Create(new TemplateDetail { Name = "JamOn" + i.ToString(), // Detail = "", IsPublished = (i % 2 == 1) }).Result; } Template t = mgr.Link(new TemplateLink { TemplateId = 5, WorkspaceId = topo.Id }).Result; t = mgr.Unlink(new TemplateLink { TemplateId = t.Id }).Result; var list = mgr.List(new Search { Take = 50, //Term = "2", Filter = new string[] { //"published" } }).Result; Assert.True(list.Length == 6); } }
public async Task <ActionResult <TemplateDetail> > CreateTemplateDetail([FromBody] NewTemplateDetail model) { await Validate(model); AuthorizeAll(); return(Ok( await _svc.Create(model) )); }
public void CanCreateAndEditTemplates() { using (TestSession test = CreateSession()) { TemplateService mgr = test.GetTemplateManager(); TemplateDetail template = mgr.Create(new TemplateDetail { Name = "JamOn", Detail = "original" }).Result; Assert.True(template.Id > 0); template.Name += "Changed"; template.Detail = "detail"; template = mgr.Configure(template).Result; Assert.Matches("Changed", template.Name); Assert.Equal("detail", template.Detail); } }
public int CreateTemplate(TemplateDTO oTemplateDTO) { try { return(TemplateService.Create(oTemplateDTO)); } catch (TimeoutException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "Critical Exception" }); } catch (Exception) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "Critical Exception" }); } }
public void ListReturnsList() { using (TestSession test = CreateSession()) { //test.AddActor("*****@*****.**"); TemplateService mgr = test.GetTemplateManager(); for (int i = 0; i < 5; i++) { TemplateDetail template = mgr.Create(new TemplateDetail { Name = "JamOn" + i.ToString(), Detail = i.ToString(), IsPublished = (i % 2 == 0) }).Result; } var list = mgr.List(new Search { Take = 50, //Term = "2", Filter = new string[] { "published" } }).Result; Assert.True(list.Length == 3); } }
/// <summary> /// Create a new template. Call <see cref="Save"/> to ensure the template /// is saved to disk /// </summary> /// <param name="alias">Template alias</param> /// <param name="name">Template name</param> /// <returns></returns> public static Template Create(string alias, string name) { return(TemplateService.Create(alias, name)); }
/// <summary> /// Create a new template. Call <see cref="Save"/> to ensure the template /// is saved to disk. The template alias is generated by removing spaces /// from the name. /// </summary> /// <param name="name">Template alias and name</param> /// <returns></returns> public static Template Create(string name) { var alias = name.Replace(" ", ""); return(TemplateService.Create(alias, name)); }
public async Task <ActionResult <TemplateDetail> > Create([FromBody] TemplateDetail model) { var result = await _templateService.Create(model); return(Ok(result)); }
public ActionResult Create([FromBody] CreateTemplateDto dto) { int id = _service.Create(dto); return(Created($"template/{id}", null)); }