Skip to content

Instantly share code, notes, and snippets.

View flaviorl-net's full-sized avatar
🎯
Focusing

Flavio flaviorl-net

🎯
Focusing
  • Itaú Unibanco
  • São Paulo - Brasil
View GitHub Profile
using TestMediator.Interfaces;
namespace TestMediator.Command
{
public class CadastrarEnderecoCommand : ICommand<string>
{
public int Id { get; private set; }
public string Logradouro { get; private set; }
public string Endereco { get; private set; }
public int Numero { get; private set; }
using System.Threading;
using System.Threading.Tasks;
using TestMediator.Interfaces;
namespace TestMediator.Mediator
{
public class Mediator : IMediator
{
private readonly MediatR.IMediator _mediator;
using System.Threading;
using System.Threading.Tasks;
namespace TestMediator.Interfaces
{
public interface IMediator
{
Task PublishEvent(object notification, CancellationToken cancellationToken = default);
Task PublishEvent<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : IEvent;
Task<TResponse> SendCommand<TResponse>(ICommand<TResponse> request, CancellationToken cancellationToken = default);
using MediatR;
namespace TestMediator.Interfaces
{
public interface IEventHandle<in TNotification> : INotificationHandler<TNotification>
where TNotification : IEvent
{
}
}
using MediatR;
namespace TestMediator.Interfaces
{
public interface IEvent : INotification
{
}
}
using MediatR;
namespace TestMediator.Interfaces
{
public interface ICommandHandle<in TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
where TRequest : ICommand<TResponse>
{
}
}
using MediatR;
namespace TestMediator.Interfaces
{
public interface ICommand<out T> : IRequest<T>
{
}
}
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using TestMediator.Notification;
namespace TestMediator.Controllers
{
[Route("api/[controller]")]
[ApiController]
using MediatR;
using System.Threading;
using System.Threading.Tasks;
using TestMediator.Notification;
namespace TestMediator.NotificationHandle
{
public class ProdutoHandle : INotificationHandler<ProdutoNotification>
{
public async Task Handle(ProdutoNotification notification, CancellationToken cancellationToken)
using MediatR;
namespace TestMediator.Notification
{
public class ProdutoNotification : INotification
{
public int ID { get; private set; }
public string Descricao { get; private set; }
public decimal Valor { get; private set; }
public int QuantidadeEstoque { get; set; }