public ActionResult <Board> GetOne([FromRoute] string id) { Board board = _boardService.Get(id); if (board == null) { return(NotFound(id)); } return(Ok(board)); }
public async Task <ActionResult <Board> > Get(string id) { UserModel currentUserModel = await userManager.GetUserAsync(HttpContext.User); if (currentUserModel.UserId == null) { return(StatusCode( StatusCodes.Status401Unauthorized, new Response { Status = "Unauthorized", Message = "userId is null" } )); } if (currentUserModel.Sessions.All(s => s.Id != id)) { return(Status403Forbidden()); } Board?board = await boardService.Get(id); if (board == null) { return(NotFound()); } return(board); }
public object GetBoard(int id) { var map = mapper.CreateMapper(); if (id != 0) { BoardDTO board = BoardService.Get(id); BoardViewModel myboard = map.Map <BoardViewModel>(board); return(JsonConvert.SerializeObject(myboard, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); } else { IEnumerable <BoardDTO> board = BoardService.GetAll(User.Identity.GetUserId()); IEnumerable <BoardViewModel> myboard = map.Map <IEnumerable <BoardViewModel> >(board); return(JsonConvert.SerializeObject(myboard.FirstOrDefault(), Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })); } }
public int Delete(int boardId) { var map = mapper.CreateMapper(); BoardDTO board = BoardService.Get(boardId); int i = BoardService.Delete(board); return(i); }
public void Get_should_return_null_if_no_matching_id() { var data = TestUtils.GetBoardData(); var service = new BoardService(TestUtils.InitBoardMoqContext(data).Object); var board = service.Get(4); Assert.True(board == null); }
public void Get_should_return_corresponding_board() { var data = TestUtils.GetBoardData(); var service = new BoardService(TestUtils.InitBoardMoqContext(data).Object); var board = service.Get(1); Assert.True(board.BoardId == 1); Assert.True(board.Name == "Board A"); }
public string SaveBoard(BoardDTO dto) { var test = _boardService.Get(); Board board = new Board() { bytes = dto.bytes }; var result = _boardService.create(board); return(result.Id); }
public int Create(string name, int id) { var map = mapper.CreateMapper(); BoardDTO board = BoardService.Get(id); TaskListDTO taskList = new TaskListDTO { Name = name, BoardId = board.Id }; int i = taskList.Id = TaskListService.Create(taskList); return(i); }
public void Get_should_return_nested_lists_and_cards() { var cards = TestUtils.GetCardData(); var lists = TestUtils.GetNestedListData(cards); var data = TestUtils.GetNestedBoardData(lists); var service = new BoardService(TestUtils.InitBoardMoqContext(data).Object); var board = service.Get(1); Assert.True(board != null); Assert.True(board.Lists.Count() > 0); Assert.True(board.Lists[0].Cards.Count() > 0); }
/// <summary> /// 글편집 /// </summary> /// <returns></returns> public IActionResult Edit(int id) { var boardService = new BoardService(); var board = boardService.Get(id); if (board == null) { return(NotFound()); } return(View(board)); }
public int RemoveUser(int boardId, string userId) { var map = mapper.CreateMapper(); BoardDTO board = BoardService.Get(boardId); UserDTO user = UserService.GetById(userId); int i = BoardService.RemoveUser(board, user); if (i > 0) { return(1); } else { return(-1); } }
private Task <Board> FetchBoard(string sessionId) => boardService.Get(sessionId);
public ActionResult <List <Board> > Get() { var userId = httpContextAccessor.HttpContext.User.Identity.Name; return(boardService.Get(userId)); }
public async Task <AActionParams> MakeActionParams( string sessionId, ActionRequest actionRequest, UserModel userModel ) { AActionParams actionParams; Game game; Board board; Models.SessionModel.Session session; string playerId = userModel.UserId; switch (actionRequest.Type) { case GameActionType.Buy: game = await gameService.Get(sessionId); actionParams = new BuyAction.Params(actionRequest, playerId, game); break; case GameActionType.Plant: game = await gameService.Get(sessionId); board = await boardService.Get(sessionId); actionParams = new PlantAction.Params(actionRequest, playerId, game, board); break; case GameActionType.Grow: game = await gameService.Get(sessionId); board = await boardService.Get(sessionId); actionParams = new GrowAction.Params(actionRequest, playerId, game, board); break; case GameActionType.Collect: game = await gameService.Get(sessionId); board = await boardService.Get(sessionId); actionParams = new CollectAction.Params(actionRequest, playerId, game, board); break; case GameActionType.EndTurn: game = await gameService.Get(sessionId); actionParams = new EndTurnAction.Params(actionRequest, playerId, game); break; case GameActionType.StartGame: game = await gameService.Get(sessionId); session = await sessionService.Get(sessionId); actionParams = new StartGameAction.Params(actionRequest, playerId, session, game); break; case GameActionType.PlaceStartingTree: game = await gameService.Get(sessionId); board = await boardService.Get(sessionId); actionParams = new PlaceStartingTreeAction.Params(actionRequest, playerId, game, board); break; case GameActionType.Undo: case GameActionType.Resign: case GameActionType.Kick: default: throw new ArgumentOutOfRangeException(); } return(actionParams); }