Get Started
Lifecycle & Coding Details
Developing a Plugin
Guides & Tutorials
Blueprint Plugin Events
Node.js Plugin Events
- Create Server
- Create Server Docker Compose
- Create Server Docker Compose Dev
- Create Server Dot Env
- Create Server Auth
- Create Package Json
- Create Entity Service
- Create Entity Service Base
- Create Entity Controller
- Create Entity Controller Base
- Create Entity Resolver
- Create Entity Resolver Base
- Create Message Broker Service
- Create Message Broker Service Base
- Create Message Broker NestJS Module
- Create Message Broker Client Options Factory
- Create Message Broker Topics Enum
- Create Prisma Schema
.NET Plugin Events
- Create Server
- Create Server Appsettings
- Create Server Auth
- Create Program File
- Create Server Csproj
- Create Server Docker Compose
- Create Server Git Ignore
- Create Entity Model
- Create Resource Db Context File
- Create Message Broker
- Create Message Broker Client Options Factory
- Create Message Broker Service
- Create Entity Controller
- Create Entity Controller Base
- Create DTOs
- Create Entity Extensions
- Create Entity Interface
- Create Entity Service
- Create Entity Service Base
- Create Seed Development Data File
- Load Static Files
.NET Plugin Events
Create Entity Service
Creates a service for a specific entity in the .NET application.
afterCreateEntityService(
context: dotnetTypes.DsgContext,
eventParams: dotnet.CreateEntityServiceParams,
files: FileMap<Class>
): Promise<FileMap<Class>> {
const { entity, resourceName, apisDir } = eventParams;
const servicePath = `${apisDir}/${entity.name}/${pascalCase(entity.name)}Service.cs`;
const serviceFile = files.get(servicePath);
if (serviceFile) {
// Add a custom method to the service
serviceFile.code.addMethod(
CsharpSupport.method({
name: "GetRecentlyModified",
access: "public",
isAsync: true,
returnType: CsharpSupport.Types.task(CsharpSupport.Types.list(CsharpSupport.Types.reference(entity.name))),
parameters: [
CsharpSupport.parameter({
name: "days",
type: CsharpSupport.Types.int(),
defaultValue: "7",
}),
],
body: `
var cutoffDate = DateTime.UtcNow.AddDays(-days);
return await _repository.GetAll()
.Where(e => e.UpdatedAt >= cutoffDate)
.OrderByDescending(e => e.UpdatedAt)
.ToListAsync();
`,
})
);
// Add necessary imports
serviceFile.code.addImport("System");
serviceFile.code.addImport("System.Linq");
serviceFile.code.addImport("Microsoft.EntityFrameworkCore");
}
return files;
}
Event Name
CreateEntityService
Event Parameters
The entity object for which the service is being created.
The name of the resource (typically the entity name).
The directory where the API services are being generated.
An object containing the CRUD actions available for the entity.
afterCreateEntityService(
context: dotnetTypes.DsgContext,
eventParams: dotnet.CreateEntityServiceParams,
files: FileMap<Class>
): Promise<FileMap<Class>> {
const { entity, resourceName, apisDir } = eventParams;
const servicePath = `${apisDir}/${entity.name}/${pascalCase(entity.name)}Service.cs`;
const serviceFile = files.get(servicePath);
if (serviceFile) {
// Add a custom method to the service
serviceFile.code.addMethod(
CsharpSupport.method({
name: "GetRecentlyModified",
access: "public",
isAsync: true,
returnType: CsharpSupport.Types.task(CsharpSupport.Types.list(CsharpSupport.Types.reference(entity.name))),
parameters: [
CsharpSupport.parameter({
name: "days",
type: CsharpSupport.Types.int(),
defaultValue: "7",
}),
],
body: `
var cutoffDate = DateTime.UtcNow.AddDays(-days);
return await _repository.GetAll()
.Where(e => e.UpdatedAt >= cutoffDate)
.OrderByDescending(e => e.UpdatedAt)
.ToListAsync();
`,
})
);
// Add necessary imports
serviceFile.code.addImport("System");
serviceFile.code.addImport("System.Linq");
serviceFile.code.addImport("Microsoft.EntityFrameworkCore");
}
return files;
}
Was this page helpful?
afterCreateEntityService(
context: dotnetTypes.DsgContext,
eventParams: dotnet.CreateEntityServiceParams,
files: FileMap<Class>
): Promise<FileMap<Class>> {
const { entity, resourceName, apisDir } = eventParams;
const servicePath = `${apisDir}/${entity.name}/${pascalCase(entity.name)}Service.cs`;
const serviceFile = files.get(servicePath);
if (serviceFile) {
// Add a custom method to the service
serviceFile.code.addMethod(
CsharpSupport.method({
name: "GetRecentlyModified",
access: "public",
isAsync: true,
returnType: CsharpSupport.Types.task(CsharpSupport.Types.list(CsharpSupport.Types.reference(entity.name))),
parameters: [
CsharpSupport.parameter({
name: "days",
type: CsharpSupport.Types.int(),
defaultValue: "7",
}),
],
body: `
var cutoffDate = DateTime.UtcNow.AddDays(-days);
return await _repository.GetAll()
.Where(e => e.UpdatedAt >= cutoffDate)
.OrderByDescending(e => e.UpdatedAt)
.ToListAsync();
`,
})
);
// Add necessary imports
serviceFile.code.addImport("System");
serviceFile.code.addImport("System.Linq");
serviceFile.code.addImport("Microsoft.EntityFrameworkCore");
}
return files;
}