public ActionResult Delete(long id) { try { documentService.DeleteModel(id); var filelist = fileService.GetServerFile(id, new CrmCusDocumentModel().GetType().ToString()); if (filelist.Any()) { foreach (var serverFile in filelist) { if (serverFile != null) { if (System.IO.File.Exists(Server.MapPath(serverFile.Path))) { System.IO.File.Delete(Server.MapPath(serverFile.Path)); } } fileService.Delete(serverFile); } } var value = new { Views = "Bạn đã xoá thành công", Title = "Success!", IsRemve = true, TdId = "del_" + id }; return(JsonResult(value, true)); } catch (Exception ex) { var result = new CommandResult(false) { ErrorResults = new[] { ex.Message } }; return(JsonResult(result, null, true)); } }
public ActionResult Delete(int id) { try { var eventItem = eventService.GetDbById(id); var filelist = fileService.GetServerFile(id, new CRMEventModel().GetType().ToString()); if (filelist.Any()) { foreach (var serverFile in filelist) { if (serverFile != null) { if (System.IO.File.Exists(Server.MapPath(serverFile.Path))) { System.IO.File.Delete(Server.MapPath(serverFile.Path)); } } fileService.Delete(serverFile); } } var follows = followEventService.GetAll(x => x.VisitId == id); if (follows.Any()) { followEventService.DeleteAll(follows); } eventService.Delete(eventItem); var value = new { Views = "Bạn đã xoá thành công", Title = "Success!", IsRemve = true, TdId = "del_" + id }; return(JsonResult(value, true)); } catch (Exception ex) { var result = new CommandResult(false) { ErrorResults = new[] { ex.Message } }; return(JsonResult(result, null, true)); } }