sledgemapper/Sledgemapper.Api/Handlers/NewNoteCommandHandler.cs
Michele Scandura 5b7ad4f2ff
All checks were successful
continuous-integration/drone/push Build is passing
fix note bugs
2021-09-23 12:47:48 +01:00

26 lines
962 B
C#

using MediatR;
using Sledgemapper.Api.Infrastructure.Data;
using Sledgemapper.Api.Commands;
using Sledgemapper.Api.Notifications;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Sledgemapper.Api.Handlers
{
public class NewNoteCommandHandler : BaseCommandHandler<NewNoteCommand, bool>
{
public NewNoteCommandHandler(IMediator mediator, SledgemapperDbContext dbcontext) : base(mediator, dbcontext)
{
}
public override async Task<bool> Handle(NewNoteCommand command, CancellationToken cancellationToken)
{
await CheckAuthorization(command);
var jsonString = JsonSerializer.Serialize(command.Note);
var session = await SaveLog(command, "N", "N", jsonString, cancellationToken);
await Mediator.Publish(new NewNoteNotification(session, command.Note, command.UserId), cancellationToken);
return true;
}
}
}