public ActionResult DeletePhoto(string id, int NewsId = 0) { var iVal = 0; Utility.Operate(this, Operations.Delete, () => { iVal = _photo.Delete(id); return(iVal); }); var page = Pagination.CheckPageIndexWhenDeleted(this, iVal); return(Redirect(string.Format("~/Admin/Cases/Show/{0}?page={1}", NewsId, page))); }
public IActionResult DeletePhoto(int id) { var photo = photoRepo.GetById(id); if (photo == null) { return(NotFound(new { Code = HttpStatusCode.NotFound, Message = "This photo is not exists" })); } var uploadFolderPath = Path.Combine(host.WebRootPath, "uploads"); var fileName = photo.FileName; var filePath = Path.Combine(uploadFolderPath, fileName); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } photoRepo.Delete(photo); uow.Save(); return(Ok(photo)); }
public async Task <IActionResult> Delete(int id) { await _photoService.Delete(id); return(RedirectToAction("Index", "Home")); }
/// <summary> /// 物理删除数据 Delete(Guid Guid) /// </summary> /// <param name="guid">主键Id(int)</param> /// <returns>true:删除成功; false:删除失败</returns> public bool Delete(string guid) { return(_photo.Delete(guid)); }