コード例 #1
0
        public async Task <IActionResult> DeleteAmenityPhoto(int photoID)
        {
            var photoFromRepo = await _photoService.GetPhoto(photoID);

            if (photoFromRepo == null)
            {
                return(NotFound());
            }

            if (photoFromRepo.IsMain)
            {
                return(BadRequest("You cannot delete the main photo."));
            }

            if (await _photoService.DeleteAmenityPhoto(photoFromRepo) > 0)
            {
                return(Ok("Photo deleted."));
            }

            return(BadRequest("Failed to delete the photo."));
        }