public async Task <IEnumerable <CampingTripFull> > Get() { var identity = (ClaimsIdentity)User.Identity; IEnumerable <Claim> claims = identity.Claims; var role = claims.Where(claim => claim.Type == "role")?.First(); if (role?.Value == "Admin") { return(await campingTripRepository.GetAllCompletedCampingTripsAsync()); } else { var userIdClaim = claims.Where(cl => cl.Type == "user_id").First(); if (!int.TryParse(userIdClaim.Value, out int userId)) { throw new Exception("Invalid user id"); } return(await campingTripRepository.GetAllCompletedCampingTripsForUserAsync()); } }