| Required role: | super-admin |
| POST | /document-template |
|---|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using tvpl.api.ServiceModel;
using tvpl.data.Models;
namespace tvpl.api.ServiceModel
{
public partial class CreateDocumentTemplateResponse
: IResponseRequest
{
public virtual int InsertedId { get; set; }
public virtual int Code { get; set; }
public virtual string Message { get; set; }
}
public partial class CreateOrUpdateTemplateRequest
{
public CreateOrUpdateTemplateRequest()
{
DocumentIds = new List<int>{};
Elements = new List<DocumentElementDto>{};
}
public virtual int? Id { get; set; }
public virtual List<int> DocumentIds { get; set; }
public virtual string Title { get; set; }
public virtual string Description { get; set; }
public virtual bool IsActive { get; set; }
public virtual List<DocumentElementDto> Elements { get; set; }
}
public partial class DocumentElementDto
: DocumentElement
{
public DocumentElementDto()
{
Children = new List<DocumentElementDto>{};
}
public virtual List<DocumentElementDto> Children { get; set; }
}
}
namespace tvpl.data.Models
{
public partial class DocumentElement
{
public virtual int Id { get; set; }
public virtual int TemplateId { get; set; }
[Required]
public virtual string ElementKey { get; set; }
[Required]
public virtual string Tag { get; set; }
public virtual int? ParentId { get; set; }
[Required]
public virtual string Title { get; set; }
public virtual string Description { get; set; }
[Required]
public virtual string DataType { get; set; }
public virtual string TemplateType { get; set; }
public virtual int OrderIndex { get; set; }
public virtual bool? IsRequired { get; set; }
}
}
C# CreateOrUpdateTemplateRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /document-template HTTP/1.1
Host: etc-api.vsmlab.vn
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateOrUpdateTemplateRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/tvpl.api.ServiceModel">
<Description>String</Description>
<DocumentIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</DocumentIds>
<Elements>
<DocumentElementDto>
<CreatedAt xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0001-01-01T00:00:00</CreatedAt>
<DataType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</DataType>
<Description xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Description>
<ElementKey xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</ElementKey>
<Id xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</Id>
<IsRequired xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">false</IsRequired>
<OrderIndex xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</OrderIndex>
<ParentId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</ParentId>
<Tag xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Tag>
<TemplateId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</TemplateId>
<TemplateType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</TemplateType>
<Title xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Title>
<Children>
<DocumentElementDto>
<CreatedAt xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0001-01-01T00:00:00</CreatedAt>
<DataType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</DataType>
<Description xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Description>
<ElementKey xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</ElementKey>
<Id xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</Id>
<IsRequired xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">false</IsRequired>
<OrderIndex xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</OrderIndex>
<ParentId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</ParentId>
<Tag xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Tag>
<TemplateId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</TemplateId>
<TemplateType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</TemplateType>
<Title xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Title>
<Children>
<DocumentElementDto>
<CreatedAt xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0001-01-01T00:00:00</CreatedAt>
<DataType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</DataType>
<Description xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Description>
<ElementKey xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</ElementKey>
<Id xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</Id>
<IsRequired xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">false</IsRequired>
<OrderIndex xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</OrderIndex>
<ParentId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</ParentId>
<Tag xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Tag>
<TemplateId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</TemplateId>
<TemplateType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</TemplateType>
<Title xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Title>
<Children i:nil="true" />
</DocumentElementDto>
</Children>
</DocumentElementDto>
</Children>
</DocumentElementDto>
</Elements>
<Id>0</Id>
<IsActive>false</IsActive>
<Title>String</Title>
</CreateOrUpdateTemplateRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CreateDocumentTemplateResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/tvpl.api.ServiceModel"> <Code>0</Code> <InsertedId>0</InsertedId> <Message>String</Message> </CreateDocumentTemplateResponse>