//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 { UserDao uDao = new UserDao(); AddressDao aDao = new AddressDao(); FitnessUser fitnessUser = uDao.GetById(id); Address address = new Address(); address = fitnessUser.Address; //pokud se jedná o trenéra, je třeba smazat jeho termíny, které vede if (fitnessUser.Role.Name == "Trenér") { TermDao tDao = new TermDao(); IList <Term> terms = tDao.GetTermsByTrainer(fitnessUser); foreach (Term t in terms) { tDao.Delete(t); } }//pokud se jedna o zakaznika, je treba smazat rezervace, na ktere je zapsan else if (fitnessUser.Role.Name == "Zákazník") { ReservationDao rDao = new ReservationDao(); IList <Reservation> reservations = rDao.GetAllReservationsByUser(fitnessUser); foreach (Reservation r in reservations) { rDao.Delete(r); } } if (fitnessUser.SmallImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/FitnessUser/" + fitnessUser.SmallImageName)); } if (fitnessUser.BigImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/FitnessUser/" + fitnessUser.BigImageName)); } uDao.Delete(fitnessUser); aDao.Delete(address); TempData["succes"] = "Uživatelský účet byl odstraněn."; if (fitnessUser.Login == User.Identity.Name) { return(RedirectToAction("Logout", "Home")); } return(RedirectToAction("Index", "Home")); } catch (Exception e) { Console.WriteLine(e); throw; } }
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")); }