|
|
**appsettings.json**
|
|
|
- Do no store sensitive information, especially passwords in appsettings.json, use the Secret Manager. Please see [Safe storage of app secrets in development in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-6.0&tabs=windows) for reference.
|
|
|
|
|
|
**Models**
|
|
|
- Store all business class data models under **\<ProjectName\>.Business/Models**
|
|
|
- Store all Kentico generated classes under **\<ProjectNam\e>.Business/Models/Generated**. No need to create subfolders unless the number of models is greater than 20, then logically group them in subfolders.
|
|
|
- No need to add Dto in the class name, example **HomePage**, not ***HomePageDto***
|
|
|
- Name the model class the same as the Kentico Generated class, you just have a different namespace
|
|
|
- Kentico Generated Class: **CMS.DocumentEngine.Types.\<ProjectName\>.HomePage**
|
|
|
- Business Model Class: **\<ProjectName\>.Business.Models.HomePage**
|
|
|
|
|
|
**Repositories**
|
|
|
- Store all repositories under **\<ProjectName\>.Business/Repositories**. No need to create subfolders unless the number of repositories is greater than 20, then logically group them in subfolders.
|
|
|
- Always inherit from **XperienceAdapter.Repositories.BasePageRepository\<\<BusinessClass\>, \<GeneratedClass\>\>**
|
|
|
- `public class HomePageRepository : BasePageRepository<HomePage, CMS.DocumentEngine.Types.<ProjectName>.HomePage>`
|
|
|
- If custom methods are needed to simplify data access to repositories, create an interface for the repository and have the repository inherit from both the interface and BasePageRepository.
|
|
|
|
|
|
```
|
|
|
public interface IHomePageRepository
|
|
|
{
|
|
|
public HomePage GetHomePage();
|
|
|
}
|
|
|
|
|
|
public class HomePageRepository : BasePageRepository<HomePage, CMS.DocumentEngine.Types.<ProjectName>.HomePage>, IHomePageRepository
|
|
|
{
|
|
|
public HomePage GetHomePage()
|
|
|
{
|
|
|
....
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
** Unit Testing **
|
|
|
- Create unit tests for all repositories with custom methods, otherwise, not needed
|
|
|
- Create unit tests for all components, mock repositories if retrieving data for the component |