public IActionResult DeletePost(Guid Id) { if (Id == null) { return(BadRequest("Post ID cannot be null")); } var post = postService.Get(Id); foreach (var item in post.MediaFiles) { string path = Path.Combine(Folder, item.fileName); //delete the post file if any UploadFile.DeleteFile(path); } postService.DeletePost(Id); return(Ok(new { message = "Post Deleted" })); }