Table of Contents

Class ControllerBase<TModel, TDto>

Namespace
Magicalizer.Api.Controllers
Assembly
Magicalizer.dll

Base of the controllers of models (the magicalized ones and the custom ones): converts models to DTOs and processes the requests around the actions, so the actions only call the services:

The DTOs are created by their constructors that take the models, so a DTO only for reading (without IDto<TModel>) is enough for a custom controller that doesn't create or update models.

[ApiController]
[QueryStringValidationFilter]
[FluentValidationFilter]
public abstract class ControllerBase<TModel, TDto> : ControllerBase where TModel : class, IModel where TDto : class, IDto

Type Parameters

TModel

Model type.

TDto

DTO type.

Inheritance
ControllerBase<TModel, TDto>
Derived
Inherited Members

Methods

ModelToDto(TModel?)

Converts the model to the DTO.

protected virtual TDto? ModelToDto(TModel? model)

Parameters

model TModel

Model to convert.

Returns

TDto

DTO, or null if the model is null.