cleanup, refactoring, usual stuff
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b671c661a7
commit
f15f1c8857
26 changed files with 183 additions and 209 deletions
|
@ -22,10 +22,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteNoteCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Note>(notification.Note);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Note);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteOverlayCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Overlay);
|
||||
var session = _dbcontext.Sessions.First(m=>m.SessionName== notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteTileCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Tile);
|
||||
var session = _dbcontext.Sessions.First(m=>m.SessionName== notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(DeleteWallCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Wall>(notification.Wall);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Wall);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "D",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Sledgemapper.Api.Handlers
|
|||
var campaigns = _dbcontext.Campaigns.Include(c => c.InvitedUsers).Include(c => c.Maps).Include(c => c.Owner).Where(campaign => campaign.OwnerId == command.UserId || campaign.InvitedUsers.Contains(user));
|
||||
|
||||
return campaigns.
|
||||
Select(c => new Shared.Entities.Campaign { Id = c.CampaignId, Name = c.CampaignName, Maps = c.Maps.Select(m => new Shared.Entities.Map { SessionName = m.SessionName }).ToList() })
|
||||
Select(c => new Campaign { Id = c.CampaignId, Name = c.CampaignName, Maps = c.Maps.Select(m => new Map { SessionName = m.SessionName }).ToList() })
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -9,17 +9,17 @@ using Sledgemapper.Api.Models;
|
|||
|
||||
namespace Sledgemapper.Api.Commands
|
||||
{
|
||||
public class GetMapSnapshotCommandHandler : IRequestHandler<GetMapSnapshotCommand, Sledgemapper.Shared.Entities.Session>
|
||||
public class GetMapSnapshotCommandHandler : IRequestHandler<GetMapSnapshotCommand, Shared.Entities.Session>
|
||||
{
|
||||
private readonly SledgemapperDbContext _dbcontext;
|
||||
|
||||
public GetMapSnapshotCommandHandler(SledgemapperDbContext dbcontext) { _dbcontext = dbcontext; }
|
||||
|
||||
public async Task<Sledgemapper.Shared.Entities.Session> Handle(GetMapSnapshotCommand notification, CancellationToken cancellationToken)
|
||||
public async Task<Shared.Entities.Session> Handle(GetMapSnapshotCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
Snapshot snapshot;
|
||||
double timestamp;
|
||||
Sledgemapper.Shared.Entities.Session mapSession;
|
||||
Shared.Entities.Session mapSession;
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
snapshot = _dbcontext.Snapshots.OrderByDescending(s => s.Timestamp).FirstOrDefault(m => m.SessionId == session.SessionId);
|
||||
if (snapshot is null)
|
||||
|
@ -30,7 +30,7 @@ namespace Sledgemapper.Api.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
mapSession = JsonSerializer.Deserialize<Sledgemapper.Shared.Entities.Session>(snapshot.Object);
|
||||
mapSession = JsonSerializer.Deserialize<Shared.Entities.Session>(snapshot.Object);
|
||||
timestamp = snapshot.Timestamp;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace Sledgemapper.Api.Commands
|
|||
{
|
||||
SessionId = session.SessionId,
|
||||
Timestamp = mapUpdates.Max(mapSession => mapSession.Timestamp),
|
||||
Object = JsonSerializer.Serialize<Sledgemapper.Shared.Entities.Session>(mapSession)
|
||||
Object = JsonSerializer.Serialize(mapSession)
|
||||
};
|
||||
await _dbcontext.Snapshots.AddAsync(newSnapshot);
|
||||
await _dbcontext.SaveChangesAsync();
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewLineCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Line>(notification.Line);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Line);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewNoteCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Note>(notification.Note);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Note);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewOverlayCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Overlay>(notification.Overlay);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Overlay);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewRoomCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Room>(notification.Room);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Room);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace Sledgemapper.Api.Commands
|
|||
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
var newSnapshot = new Sledgemapper.Api.Models.Snapshot{
|
||||
var newSnapshot = new Models.Snapshot{
|
||||
SessionId=session.SessionId,
|
||||
Timestamp=notification.Timestamp,
|
||||
Object = JsonSerializer.Serialize<Sledgemapper.Shared.Entities.Session>(notification.Session)
|
||||
Object = JsonSerializer.Serialize(notification.Session)
|
||||
|
||||
};
|
||||
await _dbcontext.Snapshots.AddAsync(newSnapshot);
|
||||
|
|
|
@ -19,10 +19,10 @@ namespace Sledgemapper.Api.Commands
|
|||
|
||||
public async Task<bool> Handle(NewTileCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Tile>(notification.Tile);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Tile);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace Sledgemapper.Api.Handlers
|
|||
|
||||
public async Task<bool> Handle(NewWallCommand notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var jsonString = JsonSerializer.Serialize<Wall>(notification.Wall);
|
||||
var jsonString = JsonSerializer.Serialize(notification.Wall);
|
||||
var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
|
||||
_dbcontext.MapLogs.Add(new Sledgemapper.Api.Models.MapLog
|
||||
_dbcontext.MapLogs.Add(new Models.MapLog
|
||||
{
|
||||
Operation = "N",
|
||||
SessionId = session.SessionId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue