public User Add([FromBody] User newUser) { // Log the API call _logger.LogInformation("Adding a new user to persistent storage"); // Get or create the user that matches the passed in username var user = _landmarkRepository.GetUser(newUser.Username); if (user == null) { user = _landmarkRepository.AddUser(newUser.Username, newUser.Fullname ?? newUser.Username); } // Return the freshly created user object return(user); }
public Landmark Add([FromBody] Landmark landmark) { // Log the API call _logger.LogInformation("Adding a landmark to persistent storage"); // Get or create the user that matches the passed in username var user = _landmarkRepository.GetUser(landmark.Username); if (user == null) { throw new Exception($"User '{landmark.Username}' not found"); } // Add the landmark return(_landmarkRepository.AddLandmark(user.Username, landmark.Latitude, landmark.Longitude, landmark.Comment)); }