//pridat upozorneni pro vypsane teminy public ActionResult Delete(int id) { try { RoomDao rDao = new RoomDao(); Room r = rDao.GetById(id); //je zapotřebí smazat nejdrive vsechny terminy v teto mistnosti, a take rezervace na tyto terminy TermDao tDao = new TermDao(); ReservationDao resDao = new ReservationDao(); IList <Term> terms = tDao.GetTermsByRoom(r); foreach (Term t in terms) { IList <Reservation> reservations = resDao.GetAllReservationsByTerm(t); foreach (Reservation res in reservations) { resDao.Delete(res); } tDao.Delete(t); } rDao.Delete(r); TempData["succes"] = "Místnost " + r.Name + " byla odstraněna, stejně tak i všechny termíny v této místnosti."; } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { try { TermDao tDao = new TermDao(); Term t = tDao.GetById(id); //je treba smazat i vsechny rezervace daneho terminu ReservationDao resDao = new ReservationDao(); IList <Reservation> reservations = resDao.GetAllReservationsByTerm(t); foreach (Reservation res in reservations) { resDao.Delete(res); } tDao.Delete(t); TempData["succes"] = "Termín i jeho rezervace jsou úspěšně smazány."; } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { try { ActivityDao aDao = new ActivityDao(); Activity a = aDao.GetById(id); if (a.SmallImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/Activity/" + a.SmallImageName)); } if (a.BigImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/Activity/" + a.BigImageName)); } //je zapotřebí smazat nejdrive vsechny terminy na tuto aktivitu, a take rezervace na tyto terminy TermDao tDao = new TermDao(); ReservationDao resDao = new ReservationDao(); IList <Term> terms = tDao.GetTermsByActivity(a); foreach (Term t in terms) { IList <Reservation> reservations = resDao.GetAllReservationsByTerm(t); foreach (Reservation res in reservations) { resDao.Delete(res); } tDao.Delete(t); } aDao.Delete(a); TempData["succes"] = "Aktivita " + a.Name + " úspěšně smazána. Stejně tak i všechny termíny na tuto akci."; } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index")); }