public async Task <IActionResult> discoverLocation(int locationId, int userId) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var user = await _repo.GetUser(userId); if (user == null) { return(NotFound()); } var location = await _repo.GetLocation(locationId); if (location == null) { return(NotFound()); } if (await _repo.UserLocationAlreadyExist(locationId, userId)) { return(BadRequest("You have already discovered this location.")); } var mobileUserLocation = new MobileUserLocation { LocationId = locationId, MobileUserId = userId }; _repo.Add(mobileUserLocation); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to add location to user")); }