public void Delete(string campingTripId) { var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; var userIdClaim = claims.Where(claim => claim.Type == "user_id")?.FirstOrDefault(); if (userIdClaim == null) { throw new Exception("user_id claim not found"); } if (!int.TryParse(userIdClaim.Value, out int userId)) { throw new Exception("Invalid value for user_id in users claims"); } campingTripRepository.RemoveUserRegistredCampingTripAsync(campingTripId, userId); }