public ActionResult Delete(int id) { try { TourDao tourDao = new TourDao(); Tour tour = tourDao.GetById(id); //System.IO.File.Delete(Server.MapPath("~/uploads/book/" + tour.ImageName)); /*******POTREBA SMAZAT REZERVACE******/ ReservationDao reservationDao = new ReservationDao(); IList <Reservation> reservations = reservationDao.GetAll(); foreach (Reservation reservation in reservations) { if (reservation.Tour.Id == id) { reservationDao.Delete(reservation); } } tourDao.Delete(tour); TempData["message-success"] = "Zajezd " + tour.Name + " byl smazan"; } catch (Exception e) { throw; } return(RedirectToAction("Index")); }
// GET: Admin/Reservation public ActionResult Index(int?page, int?item) { int itemsOnPage = item ?? 5; int pg = page ?? 1; UserDao uDao = new UserDao(); FitnessUser u = uDao.GetByLogin(User.Identity.Name); ReservationDao rDao = new ReservationDao(); IList <Reservation> res = null; if (u.Role.Name == "Zákazník") { res = rDao.GetReservationPageByUser(itemsOnPage, pg, u); } else { res = rDao.GetReservationPage(itemsOnPage, pg); } ViewBag.Pages = (int)Math.Ceiling((double)rDao.GetAll().Count / (double)itemsOnPage); ViewBag.CurrentPage = pg; ViewBag.Items = itemsOnPage; ViewBag.Mark = "Reservation"; if (Request.IsAjaxRequest()) { return(PartialView(res)); } return(View(res)); }
public ActionResult Rezervace() { ReservationDao reservationDao = new ReservationDao(); IList <Reservation> reservations = reservationDao.GetAll(); KnihovnaUser user = new KnihovnaUserDao().GetByLogin(User.Identity.Name); if (user.Role.Identificator != "admin") { return(View("RezervaceCtenar", reservations)); } return(View(reservations)); }