public async Task <IActionResult> OnGetAsync(int id) { try { Boards = await _boardsServices.GetOneBoard(id); return(Page()); } catch (Exception) { return(RedirectToPage("../Error")); } }
public async Task <IActionResult> OnGetAsync(int SelectedId) { try { Posts = await _postsServices.GetPostsByBoards(SelectedId); Boards = await _boardsServices.GetOneBoard(Posts[0].BoardId); return(Page()); } catch (Exception) { return(RedirectToPage("../Error")); } }
public async Task <int> UpdateBoard(BoardsDTO boardsDTO) { try { int result = await _boardsRepository.UpdateBoard(_mappingService._mapper.Map <Boards>(boardsDTO)); LogInformation($"Successfully updated a board : boardId { boardsDTO.BoardId} :"); return(result); } catch (Exception ex) { LogError($"Failed to update a board : boardId { boardsDTO.BoardId} :", ex); return(1); } }
public async Task <IActionResult> OnGetAsync(int id) { try { Posts = await _postsServices.GetPostById(id); Boards = await _boardsServices.GetOneBoard(Posts.BoardId); Users = await _usersServices.GetUserById(Posts.UserId); return(Page()); } catch (Exception) { return(RedirectToPage("../Error")); } }
public async Task <BoardsDTO> GetOneBoard(int BoardId) { if (BoardId == 0) { return(null); } try { BoardsDTO board = _mappingService._mapper.Map <BoardsDTO>(await _boardsRepository.GetOneBoard(BoardId)); LogInformation($"Successfully fetched a Board : boardId {board.BoardId}, Title {board.Title} :"); return(board); } catch (Exception ex) { LogError($"Failed to fetch a Board : boardId {BoardId}", ex); return(null); } }
public async Task<IActionResult> OnPostAsync(int id) { try { Boards = await _boardsServices.GetOneBoard(id); if (Title != null) { Boards.Title = Title; await _boardsServices.UpdateBoard(Boards); } else await _boardsServices.UpdateBoard(Boards); return RedirectToPage("ViewAllBoards"); } catch (Exception) { return RedirectToPage("../Error"); } }