/CodeGenerator.Domain

Domain library used in projects created by the Code Generator tool.

Primary LanguageC#MIT LicenseMIT

Tolitech.CodeGenerator.Domain

Domain library used in projects created by the Code Generator tool.

This project contains abstract base classes, interfaces and markup interfaces to standardize and facilitate the implementation of projects generated by the Tolitech Code Generator tool.

Tolitech Code Generator Tool: http://www.tolitech.com.br

Examples:

public class Person : Entity
{
    public Person(string? name)
    {
        Name = name;
    }

    public string? Name { get; private set; }
}
public interface IPersonRepository : IRepository
{
    NotificationResult Insert(Person entity);

    IEnumerable<Person> Get();
}
public class InsertCommand : Command
{
    public string? Name { get; set; }
}
public class InsertCommandHandler : CommandHandler
{
    private readonly IPersonRepository _personRepository;

    public InsertCommandHandler(IPersonRepository personRepository)
    {
        _personRepository = personRepository;
    }

    public NotificationResult Handle(InsertCommand command)
    {
        var person = new Entities.Person(command.Name);
        var result = _personRepository.Insert(person);
        return result;
    }
}
public class GetAllQueryHandler : QueryHandler
{
    private readonly IPersonRepository _personRepository;

    public GetAllQueryHandler(IPersonRepository personRepository)
    {
        _personRepository = personRepository;
    }

    public IEnumerable<GetAllQueryResult> Handle(GetAllQuery query)
    {
        var result = new List<GetAllQueryResult>();

        var items = _personRepository.Get();

        foreach (var item in items)
        {
            result.Add(new GetAllQueryResult
            {
                Name = item.Name
            });
        }

        return result;
    }
}