Browse Source

Add best practice for DTOs of modules.

pull/640/head
Halil ibrahim Kalkan 8 years ago
parent
commit
5e460dfe65
  1. 6
      docs/en/Best-Practices/Application-Services.md
  2. 3
      docs/en/Best-Practices/Data-Transfer-Objects.md

6
docs/en/Best-Practices/Application-Services.md

@ -26,6 +26,7 @@
Example:
```c#
[Serializable]
public class IssueDto : FullAuditedEntityDto<Guid>
{
public string Title { get; set; }
@ -34,6 +35,7 @@ public class IssueDto : FullAuditedEntityDto<Guid>
public Collection<IssueLabelDto> Labels { get; set; }
}
[Serializable]
public class IssueLabelDto
{
public Guid IssueId { get; set; }
@ -54,6 +56,7 @@ public class IssueLabelDto
Example:
````C#
[Serializable]
public class IssueWithDetailsDto : FullAuditedEntityDto<Guid>
{
public string Title { get; set; }
@ -62,12 +65,14 @@ public class IssueWithDetailsDto : FullAuditedEntityDto<Guid>
public Collection<LabelDto> Labels { get; set; }
}
[Serializable]
public class MilestoneDto : EntityDto<Guid>
{
public string Name { get; set; }
public bool IsClosed { get; set; }
}
[Serializable]
public class LabelDto : EntityDto<Guid>
{
public string Name { get; set; }
@ -129,6 +134,7 @@ Task<QuestionWithDetailsDto> CreateAsync(CreateQuestionDto questionDto);
The related **DTO**:
````C#
[Serializable]
public class CreateQuestionDto
{
[Required]

3
docs/en/Best-Practices/Data-Transfer-Objects.md

@ -4,4 +4,5 @@
* **Do** inherit from the pre-built **base DTO classes** where possible and necessary (like `EntityDto<TKey>`, `CreationAuditedEntityDto<TKey>`, `AuditedEntityDto<TKey>`, `FullAuditedEntityDto<TKey>` and so on).
* **Do** define DTO members with **public getter and setter**.
* **Do** use **data annotations** for **validation** on the properties of DTOs those are inputs of the service.
* **Do** not add any **logic** into DTOs except implementing `IValidatableObject` when necessary.
* **Do** not add any **logic** into DTOs except implementing `IValidatableObject` when necessary.
* **Do** mark all DTOs as **[Serializable]** since they are already serializable and developers may want to binary serialize them.
Loading…
Cancel
Save