public ActionResult <PieceRead> Start(PieceCreate pieceRead) { var piecePosition = new Core.Entities.Position(pieceRead.Position.Row, pieceRead.Position.Col); var piece = new Piece( piecePosition, (Core.Entities.PieceType)pieceRead.PieceType); piece.Move(piecePosition); _pieceRepostiory.SavePiece(piece); return(Ok(piece.ToPieceRead())); }
public ActionResult <Piece> Move(PieceUpdate pieceUpdate) { var piece = _pieceRepostiory.GetPiece(); var piecePosition = new Core.Entities.Position(pieceUpdate.Position.Row, pieceUpdate.Position.Col); if (!piece.IsCorrectMove(piecePosition)) { return(UnprocessableEntity("Not allowed move")); } else { piece.Move(piecePosition); return(Ok(piece.ToPieceRead())); } }
public static Application.Models.Position ToPosition(this Core.Entities.Position position) { return(new Application.Models.Position(position.Row, position.Col)); }