public async Task <string> AddBattleship(Ship ship) { try { if (IsInvalidShipPosition(ship)) { return("Invalid ship coordinates or orientation"); } var boards = _repositoryService.GetBoards(ship.BoardName).Result; Console.WriteLine(JsonConvert.SerializeObject(boards)); var board = boards.FirstOrDefault(); if (board == null) { return("failed to add ship"); } board.Ships = new List <Ship> { ship }; await _repositoryService.AddShip(board); return("success"); } catch (Exception ex) { Console.WriteLine(ex.Message); return("Cannot find the board, please create the board"); } }