refactoring
This commit is contained in:
parent
9c100531ef
commit
92f333a4c4
26 changed files with 860 additions and 491 deletions
|
@ -19,10 +19,34 @@ namespace Sledgemapper.Api.Controllers
|
|||
await _mediator.Publish(new NewTileNotification(sessionName, tile));
|
||||
}
|
||||
|
||||
[HttpPost("session")]
|
||||
[HttpPost("overlay")]
|
||||
public async Task Post(string sessionName, [FromBody]Overlay overlay)
|
||||
{
|
||||
await _mediator.Publish(new NewOverlayNotification(sessionName, overlay));
|
||||
}
|
||||
|
||||
[HttpPost("wall")]
|
||||
public async Task Post(string sessionName, [FromBody]Wall wall)
|
||||
{
|
||||
await _mediator.Publish(new NewWallNotification(sessionName, wall));
|
||||
}
|
||||
|
||||
[HttpDelete("tile")]
|
||||
public async Task Delete(string sessionName, [FromBody]Tile tile)
|
||||
{
|
||||
await _mediator.Publish(new DeleteTileNotification(sessionName, tile));
|
||||
}
|
||||
|
||||
[HttpDelete("overlay")]
|
||||
public async Task Delete(string sessionName, [FromBody]Overlay overlay)
|
||||
{
|
||||
await _mediator.Publish(new DeleteOverlayNotification(sessionName, overlay));
|
||||
}
|
||||
|
||||
[HttpDelete("wall")]
|
||||
public async Task Delete(string sessionName, [FromBody]Wall wall)
|
||||
{
|
||||
await _mediator.Publish(new DeleteWallNotification(sessionName, wall));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Clients;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public abstract class BaseNotification : INotification
|
||||
{
|
||||
public double Timestamp { get; private set; }
|
||||
public string SessionName { get; private set; }
|
||||
|
||||
public BaseNotification(string sessionName)
|
||||
{
|
||||
Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
SessionName = sessionName;
|
||||
}
|
||||
}
|
||||
|
||||
public class NewTileNotification : BaseNotification
|
||||
{
|
||||
public Tile Tile { get; private set; }
|
||||
|
||||
public NewTileNotification(string sessionName, Tile tile) : base(sessionName)
|
||||
{
|
||||
Tile = tile;
|
||||
}
|
||||
}
|
||||
|
||||
public class NewOverlayNotification : BaseNotification
|
||||
{
|
||||
public Overlay Overlay { get; private set; }
|
||||
|
||||
public NewOverlayNotification(string sessionName, Overlay overlay) : base(sessionName)
|
||||
{
|
||||
Overlay = overlay;
|
||||
}
|
||||
}
|
||||
|
||||
public class SendNewTileMessage : INotificationHandler<NewTileNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendNewTileMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(NewTileNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).NewTile(notification.Tile);
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveNewTile : INotificationHandler<NewTileNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveNewTile(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(NewTileNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "T",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public class SendNewOverlayMessage : INotificationHandler<NewOverlayNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendNewOverlayMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(NewOverlayNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).NewOverlay(notification.Overlay);
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveNewOverlay : INotificationHandler<NewOverlayNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveNewOverlay(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(NewOverlayNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "O",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
32
Sledgemapper.Api/Handlers/SaveDeleteOverlay.cs
Normal file
32
Sledgemapper.Api/Handlers/SaveDeleteOverlay.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using MediatR;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SaveDeleteOverlay : INotificationHandler<DeleteOverlayNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveDeleteOverlay(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(DeleteOverlayNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "O",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
31
Sledgemapper.Api/Handlers/SaveDeleteTile.cs
Normal file
31
Sledgemapper.Api/Handlers/SaveDeleteTile.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using MediatR;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SaveDeleteTile : INotificationHandler<DeleteTileNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveDeleteTile(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(DeleteTileNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "T",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
35
Sledgemapper.Api/Handlers/SaveDeleteWall.cs
Normal file
35
Sledgemapper.Api/Handlers/SaveDeleteWall.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
|
||||
public class SaveDeleteWall : INotificationHandler<DeleteWallNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveDeleteWall(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(DeleteWallNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Wall>(notification.Wall);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "W",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
32
Sledgemapper.Api/Handlers/SaveNewOverlay.cs
Normal file
32
Sledgemapper.Api/Handlers/SaveNewOverlay.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using MediatR;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SaveNewOverlay : INotificationHandler<NewOverlayNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveNewOverlay(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(NewOverlayNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "O",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
31
Sledgemapper.Api/Handlers/SaveNewTile.cs
Normal file
31
Sledgemapper.Api/Handlers/SaveNewTile.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using MediatR;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SaveNewTile : INotificationHandler<NewTileNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveNewTile(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(NewTileNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "T",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
31
Sledgemapper.Api/Handlers/SaveNewWall.cs
Normal file
31
Sledgemapper.Api/Handlers/SaveNewWall.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using MediatR;
|
||||
using Sledgemapper.Api.Data;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SaveNewWall : INotificationHandler<NewWallNotification>
|
||||
{
|
||||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
public SaveNewWall(MyDbContext dbcontext) => _dbcontext = dbcontext;
|
||||
|
||||
public async Task Handle(NewWallNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Wall>(notification.Wall);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = notification.SessionName,
|
||||
Type = "W",
|
||||
Timestamp = notification.Timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
21
Sledgemapper.Api/Handlers/SendDeleteOverlayMessage.cs
Normal file
21
Sledgemapper.Api/Handlers/SendDeleteOverlayMessage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Clients;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SendDeleteOverlayMessage : INotificationHandler<DeleteOverlayNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendDeleteOverlayMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(DeleteOverlayNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).DeleteOverlay(notification.Overlay);
|
||||
}
|
||||
}
|
||||
}
|
21
Sledgemapper.Api/Handlers/SendDeleteTileMessage.cs
Normal file
21
Sledgemapper.Api/Handlers/SendDeleteTileMessage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Clients;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SendDeleteTileMessage : INotificationHandler<DeleteTileNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendDeleteTileMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(DeleteTileNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).DeleteTile(notification.Tile);
|
||||
}
|
||||
}
|
||||
}
|
21
Sledgemapper.Api/Handlers/SendDeleteWallMessage.cs
Normal file
21
Sledgemapper.Api/Handlers/SendDeleteWallMessage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Clients;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SendDeleteWallMessage : INotificationHandler<DeleteWallNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendDeleteWallMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(DeleteWallNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).DeleteWall(notification.Wall);
|
||||
}
|
||||
}
|
||||
}
|
21
Sledgemapper.Api/Handlers/SendNewOverlayMessage.cs
Normal file
21
Sledgemapper.Api/Handlers/SendNewOverlayMessage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Clients;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SendNewOverlayMessage : INotificationHandler<NewOverlayNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendNewOverlayMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(NewOverlayNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).NewOverlay(notification.Overlay);
|
||||
}
|
||||
}
|
||||
}
|
21
Sledgemapper.Api/Handlers/SendNewTileMessage.cs
Normal file
21
Sledgemapper.Api/Handlers/SendNewTileMessage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Clients;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SendNewTileMessage : INotificationHandler<NewTileNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendNewTileMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(NewTileNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).NewTile(notification.Tile);
|
||||
}
|
||||
}
|
||||
}
|
21
Sledgemapper.Api/Handlers/SendNewWallMessage.cs
Normal file
21
Sledgemapper.Api/Handlers/SendNewWallMessage.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SignalRChat.Hubs;
|
||||
using Sledgemapper.Clients;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class SendNewWallMessage : INotificationHandler<NewWallNotification>
|
||||
{
|
||||
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
|
||||
|
||||
public SendNewWallMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
|
||||
|
||||
public async Task Handle(NewWallNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _hub.Clients.Groups(notification.SessionName).NewWall(notification.Wall);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ namespace SignalRChat.Hubs
|
|||
private readonly MyDbContext _dbcontext;
|
||||
|
||||
// public SledgemapperHub(IMediator mediator) => _mediator = mediator;
|
||||
public SledgemapperHub(MyDbContext dbcontext, IMediator mediator) { _dbcontext = dbcontext; _mediator=mediator;}
|
||||
public SledgemapperHub(MyDbContext dbcontext, IMediator mediator) { _dbcontext = dbcontext; _mediator = mediator; }
|
||||
private static Dictionary<string, SessionData> _sessions = new Dictionary<string, SessionData>();
|
||||
public List<string> Colors = new List<string>{"CC0000",
|
||||
"CC3300",
|
||||
|
@ -45,10 +45,15 @@ namespace SignalRChat.Hubs
|
|||
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(tile);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog{
|
||||
Operation="N", SessionName=sessionName, Type="T", Timestamp=timestamp, Object=jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = sessionName,
|
||||
Type = "T",
|
||||
Timestamp = timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
|
||||
await Clients.Group(sessionName).NewTile(tile);
|
||||
}
|
||||
|
@ -73,12 +78,17 @@ await _dbcontext.SaveChangesAsync();
|
|||
_sessions[sessionName].Overlays.TryRemove(t.ToString(), out var rtile);
|
||||
}
|
||||
_sessions[sessionName].Overlays.TryAdd(tile.ToString(), tile);
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(tile);
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(tile);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog{
|
||||
Operation="N", SessionName=sessionName, Type="O", Timestamp=timestamp, Object=jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionName = sessionName,
|
||||
Type = "O",
|
||||
Timestamp = timestamp,
|
||||
Object = jsonString
|
||||
});
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
await Clients.Group(sessionName).NewOverlay(tile);
|
||||
}
|
||||
|
||||
|
|
17
Sledgemapper.Api/Notifications/BaseNotification.cs
Normal file
17
Sledgemapper.Api/Notifications/BaseNotification.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using MediatR;
|
||||
using System;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public abstract class BaseNotification : INotification
|
||||
{
|
||||
public double Timestamp { get; private set; }
|
||||
public string SessionName { get; private set; }
|
||||
|
||||
public BaseNotification(string sessionName)
|
||||
{
|
||||
Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
SessionName = sessionName;
|
||||
}
|
||||
}
|
||||
}
|
14
Sledgemapper.Api/Notifications/DeleteOverlayNotification.cs
Normal file
14
Sledgemapper.Api/Notifications/DeleteOverlayNotification.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class DeleteOverlayNotification : BaseNotification
|
||||
{
|
||||
public Overlay Overlay { get; private set; }
|
||||
|
||||
public DeleteOverlayNotification(string sessionName, Overlay overlay) : base(sessionName)
|
||||
{
|
||||
Overlay = overlay;
|
||||
}
|
||||
}
|
||||
}
|
14
Sledgemapper.Api/Notifications/DeleteTileNotification.cs
Normal file
14
Sledgemapper.Api/Notifications/DeleteTileNotification.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class DeleteTileNotification : BaseNotification
|
||||
{
|
||||
public Tile Tile { get; private set; }
|
||||
|
||||
public DeleteTileNotification(string sessionName, Tile tile) : base(sessionName)
|
||||
{
|
||||
Tile = tile;
|
||||
}
|
||||
}
|
||||
}
|
14
Sledgemapper.Api/Notifications/DeleteWallNotification.cs
Normal file
14
Sledgemapper.Api/Notifications/DeleteWallNotification.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class DeleteWallNotification : BaseNotification
|
||||
{
|
||||
public Wall Wall { get; private set; }
|
||||
|
||||
public DeleteWallNotification(string sessionName, Wall wall) : base(sessionName)
|
||||
{
|
||||
Wall = wall;
|
||||
}
|
||||
}
|
||||
}
|
14
Sledgemapper.Api/Notifications/NewOverlayNotification.cs
Normal file
14
Sledgemapper.Api/Notifications/NewOverlayNotification.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class NewOverlayNotification : BaseNotification
|
||||
{
|
||||
public Overlay Overlay { get; private set; }
|
||||
|
||||
public NewOverlayNotification(string sessionName, Overlay overlay) : base(sessionName)
|
||||
{
|
||||
Overlay = overlay;
|
||||
}
|
||||
}
|
||||
}
|
14
Sledgemapper.Api/Notifications/NewTileNotification.cs
Normal file
14
Sledgemapper.Api/Notifications/NewTileNotification.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class NewTileNotification : BaseNotification
|
||||
{
|
||||
public Tile Tile { get; private set; }
|
||||
|
||||
public NewTileNotification(string sessionName, Tile tile) : base(sessionName)
|
||||
{
|
||||
Tile = tile;
|
||||
}
|
||||
}
|
||||
}
|
14
Sledgemapper.Api/Notifications/NewWallNotification.cs
Normal file
14
Sledgemapper.Api/Notifications/NewWallNotification.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Sledgemapper.Shared.Entities;
|
||||
|
||||
namespace Sledgemapper.Api.Handlers
|
||||
{
|
||||
public class NewWallNotification : BaseNotification
|
||||
{
|
||||
public Wall Wall { get; private set; }
|
||||
|
||||
public NewWallNotification(string sessionName, Wall wall) : base(sessionName)
|
||||
{
|
||||
Wall = wall;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue