// // GET: /File/Delete/5 public ActionResult DeleteImage(int id, bool ajax = false) { if (files.ValidateImageID(id)) { files.DeleteFile(id); if (ajax) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } return(RedirectToAction("Details", "Product", new { id = id })); } if (ajax) { return(Json(new { success = false })); } return(RedirectToAction("Index", "Category")); }
public async Task <IActionResult> DeleteFile(DeleteFileAddressModel model) { var(folders, fileName) = _folderSplitter.SplitToFoldersAndFile(model.FolderNames); var folder = await _folderRepo.GetFolderAsOwner(model.AccessToken, model.SiteName, folders); if (folder == null) { return(this.Protocol(ErrorType.NotFound, "Locate folder failed!")); } var file = await _fileRepo.GetFileInFolder(folder, fileName); if (file == null) { return(this.Protocol(ErrorType.NotFound, "The file cannot be found. Maybe it has been deleted.")); } await _fileRepo.DeleteFile(file.Id); return(this.Protocol(ErrorType.Success, $"Successfully deleted the file '{file.FileName}'")); }