26 lines
962 B
C#
26 lines
962 B
C#
using MediatR;
|
|
using Sledgemapper.Api.Infrastructure.Data;
|
|
using Sledgemapper.Api.Commands;
|
|
using System.Text.Json;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Sledgemapper.Api.Notifications;
|
|
|
|
namespace Sledgemapper.Api.Handlers
|
|
{
|
|
public class NewLineCommandHandler : BaseCommandHandler<NewLineCommand, bool>
|
|
{
|
|
public NewLineCommandHandler(IMediator mediator, SledgemapperDbContext dbcontext) : base(mediator, dbcontext)
|
|
{
|
|
}
|
|
|
|
public override async Task<bool> Handle(NewLineCommand command, CancellationToken cancellationToken)
|
|
{
|
|
await CheckAuthorization(command);
|
|
var jsonString = JsonSerializer.Serialize(command.Line);
|
|
var session = await SaveLog(command, "N", "L", jsonString, cancellationToken);
|
|
await Mediator.Publish(new NewLineNotification(session, command.Line, command.UserId), cancellationToken);
|
|
return true;
|
|
}
|
|
}
|
|
}
|