using DbController; using Tabletop.Core.Models; namespace Tabletop.Core.Services { public class MoveService : IModelService { public async Task CreateAsync(Move input, IDbController dbController, CancellationToken cancellationToken = default) { string sql = $@"INSERT INTO Moves ( PlayerId, GameId, TurnNr, MoveNr, StartMove, EndMove ) VALUES ( @PLAYER_ID @GAME_ID, @TURN_NR, @MOVE_NR, @START_MOVE, @END_END ); {dbController.GetLastIdSql()}"; input.MoveId = await dbController.GetFirstAsync(sql, input.GetParameters(), cancellationToken); } public Task DeleteAsync(Move input, IDbController dbController, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } public Task GetAsync(int identifier, IDbController dbController, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } public async Task UpdateAsync(Move input, IDbController dbController, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); string sql = @"UPDATE Moves SET PlayerId = @PLAYER_ID, GameId = @GAME_ID, TurnNr = @TURN_NR, MoveNr = @MOVE_NR, StartMove = @START_MOVE, EndMove = @END_END WHERE MoveId = @MOVE_ID"; await dbController.QueryAsync(sql, input.GetParameters(), cancellationToken); } } }