public QueryResponse <BoardDto> GetBoardByCardId(string cardObfuscatedId, string userId) { var cardId = _obfuscator.Deobfuscate(cardObfuscatedId); QueryResponse <BoardDto> result; if (!_cardRepository.CardExists(cardId)) { result = new QueryResponse <BoardDto>() { ResponseDto = null, HttpStatusCode = HttpStatusCode.NotFound }; return(result); } var userBoard = _userBoardRepository.GetUserBoardByCardId(cardId, userId); if (userBoard == null) { result = new QueryResponse <BoardDto>() { ResponseDto = null, HttpStatusCode = HttpStatusCode.Forbidden }; return(result); } result = HandleGettingBoard(userId, userBoard); return(result); }
public async Task Given_A_Card_Id_Should_Invoke_CardExists_Method_Once() { // Arrange const long cardId = 4322; _cardRepository.CardExists(Arg.Any <long>()).Returns(true); // Act await _sut.CardExists(cardId); // Assert await _cardRepository.Received(1).CardExists(Arg.Is(cardId)); }
public IActionResult GetComments(int cardId) { try { if (!_cardRepository.CardExists(cardId)) { _logger.LogInformation($"Card with {cardId} wasn't found."); return(NotFound()); } var commentsForCard = _cardRepository.GetComments(cardId); var commentsForCardResult = Mapper.Map <IEnumerable <CommentDto> >(commentsForCard); return(Ok(commentsForCardResult)); } catch (Exception ex) { _logger.LogInformation($"Exception while getting comments for card with id {cardId}.", ex); return(StatusCode(500, "A problem happened while hendling your request.")); } }
public Task <bool> CardExists(long id) { return(_cardRepository.CardExists(id)); }
public bool CardExists(string cardNumber) { var cardExists = _cardRepository.CardExists(cardNumber); return(cardExists); }