public ActionResult Delete(int id) { try { MachineDao mDao = new MachineDao(); Machine m = mDao.GetById(id); if (m.SmallImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/Machine/" + m.SmallImageName)); } if (m.BigImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/Machine/" + m.BigImageName)); } mDao.Delete(m); TempData["succes"] = "Stroj " + m.Name + " úspěšně smazán."; } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index")); }
public ActionResult DeletePicture(int id) { try { MachineDao mDao = new MachineDao(); Machine m = mDao.GetById(id); if (m.SmallImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/Machine/" + m.SmallImageName)); } if (m.BigImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/Machine/" + m.BigImageName)); } m.SmallImageName = null; m.BigImageName = null; TempData["succes"] = "Obrázek stroje odstraněn."; return(View("Edit", m)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public ActionResult EditFault(int id) { MachineDao mDao = new MachineDao(); ViewBag.Mark = "Machine"; return(View(mDao.GetById(id))); }
public ActionResult Detail(int id) { MachineDao mDao = new MachineDao(); Machine mach = mDao.GetById(id); ViewBag.Mark = "Machine"; if (Request.IsAjaxRequest()) { return(PartialView(mach)); } return(View(mach)); }