public async Task <ActionResult <Location> > AddLocation(Location newLocation) { try { if (newLocation == null) { return(BadRequest()); } var existingLoc = await locationRepository.CheckIfLocationExists(newLocation.LibraryName); if (existingLoc != null) { return(BadRequest("Library Already Exists")); } var result = await locationRepository.AddLocation(newLocation); return(CreatedAtAction(nameof(GetLocation), new { id = newLocation.id }, newLocation)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database")); } }