sledgemapper/Sledgemapper.Api/Handlers/StartNewSessionHandler.cs
Michele Scandura 1ae0ee5a8a rectoring
2020-11-13 21:38:36 +00:00

32 lines
966 B
C#

using MediatR;
using Sledgemapper.Api.Commands;
using Sledgemapper.Api.Data;
using Sledgemapper.Api.Models;
using System.Threading;
using System.Threading.Tasks;
namespace Sledgemapper.Api.Handlers
{
public class StartNewSessionHandler : IRequestHandler<NewSessionCommand, bool>
{
private readonly IMediator _mediator;
private readonly MyDbContext _dbcontext;
public StartNewSessionHandler(IMediator mediator, MyDbContext dbcontext)
{
_mediator = mediator;
_dbcontext = dbcontext;
}
public async Task<bool> Handle(NewSessionCommand notification, CancellationToken cancellationToken)
{
// _dbcontext.MapLogs.Add(new Session
// {
// SessionName = notification.SessionName,
// OwnerUserId = notification.UserId
// });
await _dbcontext.SaveChangesAsync();
return true;
}
}
}