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
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue