public async Task <IActionResult> UpdateCredit([FromRoute] int creditId, [FromBody] UpdateCreditRequest request)
        {
            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 creditInDb = await _creditService.GetCreditAsync(creditId);

            if (creditInDb == null)
            {
                return(NotFound(new ErrorResponse(new ErrorModel {
                    Message = $"There is no credit with id: {creditId}"
                })));
            }

            if (creditInDb.UserId != userId)
            {
                return(Forbid());
            }

            var updateCredit = await _creditService.UpdateCreditAsync(request, creditId);

            if (!updateCredit)
            {
                return(BadRequest(new ErrorResponse(new ErrorModel {
                    Message = $"Could not update credit with id:{creditId}"
                })));
            }

            var updatedCredit = await _creditService.GetCreditAsync(creditId);

            return(Ok(new Response <CreditResponse>(_mapper.Map <CreditResponse>(updatedCredit))));
        }