public async Task <ActionResult> Delete(int id) { var circleTopicFromRepo = await _repo.GetCircleTopic(id); if (circleTopicFromRepo == null) { return(NotFound()); } if (!await MatchAppUserWithToken((int)circleTopicFromRepo.AppUserId)) { return(Unauthorized()); } var allTopicPhotos = await _repo.GetAllCommentPhotosForCircleTopic(circleTopicFromRepo.Id); _repo.Delete(circleTopicFromRepo); await _repo.SaveAll(); if (circleTopicFromRepo.PhotoId != null) { _repo.Delete(circleTopicFromRepo.Photo); var task = this._imageFileStorageManager.DeleteImageFileAsync(circleTopicFromRepo.Photo); } foreach (var topicPhoto in allTopicPhotos) { _repo.Delete(topicPhoto); var task = this._imageFileStorageManager.DeleteImageFileAsync(topicPhoto); } await _repo.SaveAll(); return(Ok()); }