32 lines
966 B
C#
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;
|
|
}
|
|
}
|
|
}
|