Exemple #1
0
        public async Task <IActionResult> UpdateLandmark([FromBody] Landmark landmark)
        {
            if (landmark == null)
            {
                return(BadRequest());
            }

            if (landmark.LandmarkName == string.Empty)
            {
                ModelState.AddModelError("Landmark Name", "The landmark name cannot be empty");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var landmarkToUpdate = await _landmarkRepository.GetLandmark(landmark.LandmarkId);

            if (landmarkToUpdate == null)
            {
                return(NotFound()); // status 404
            }
            await _landmarkRepository.UpdateLandmark(landmark);

            return(NoContent()); //success
        }