// GET: Procedure/Delete/5 public ActionResult DeleteProcedure(int id, int productId) { if (id == 0 || productId == 0) { @ViewBag.Error = "Error happened in DeleteProcedure method: no Id in GET request."; return(View("Error")); } try { var procedureDocs = _procedureService.GetItem(id).ProcedureDocuments.ToList(); var targetFolder = Server.MapPath($"~/Upload/Documents/Procedures/"); foreach (var doc in procedureDocs) { DeleteFile(doc.PathToDocument, targetFolder); } _procedureService.DeleteItem(id); _procedureService.Commit(); _currentUser = GetCurrentUser(); TempData["Success"] = Resources.Messages.ProcedureDeletedSuccess; Logger.Log.Info($"{_currentUser.Email} Deleted Procedure #{id} for Product #{productId} "); return(RedirectToAction("ProductProcedures", new { id = productId })); } catch (Exception ex) { @ViewBag.Error = ex.Message; return(View("Error")); } }