public async Task <IActionResult> GetCredit([FromRoute] int creditId) { var userId = User.Claims.FirstOrDefault(c => c.Type == "id").Value; // check if user exists var userExists = await _identityService.CheckIfUserExists(userId); if (!userExists) { return(NotFound(new ErrorResponse(new ErrorModel { Message = $"There is no user with id: {userId}" }))); } var credit = await _creditService.GetCreditAsync(creditId); if (credit == null) { return(NotFound(new ErrorResponse(new ErrorModel { Message = $"There is no credit with id: {creditId}" }))); } if (credit.UserId != userId) { return(Forbid()); } return(Ok(new Response <CreditResponse>(_mapper.Map <CreditResponse>(credit)))); }