Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
languagec#
firstline1
titleWhiteHouseService.cs
linenumberstrue
// Domain service interface
public interface IWhiteHouseService : IDomainService
{
    Task<DtoResponseBase<PresidentDto>> InsertPresidentAsync(PresidentDto request);
}
 
// Domain service
public class WhiteHouseService : DomainService<IWhiteHouseRepository>, IWhiteHouseService
{
    private readonly IEventBus _eventBus;
 
    public WhiteHouseService(IWhiteHouseRepository repository, IEventBus eventBus)
        : base(repository)
    {
        _eventBus = eventBus;
    }
 
    public Task<DtoResponseBase<PresidentDto>> InsertPresidentAsync(PresidentDto request)
    {
        var response = new DtoResponseBase<PresidentDto>();
        var builder = new PresidentBuilder()
            .WithId(item.Id)
            .WithName(item.Name);
 
        var build = builder.Build();
        if (!build.Success)
        {
            response.AddNotifications(build.Notifications);
            return response;
        }
 
        var presidentCreated = await Repository.InsertPresidentAsync(presidentsrequest);
        response.Data = presidentCreated;
 
        // Trigger event
        _eventBus.Trigger(new PresidentCreatedEvent(presidentCreated));
        return response;
    }
}

...