public ActionResult Edit(int id) { TermDao tDao = new TermDao(); ViewBag.Rooms = new RoomDao().GetAll(); ViewBag.Activities = new ActivityDao().GetAll(); ViewBag.Start = tDao.GetById(id).StartTerm; ViewBag.TimeLong = (int)(tDao.GetById(id).EndTerm.Subtract(tDao.GetById(id).StartTerm).Minutes); ViewBag.Mark = "Term"; return(View(tDao.GetById(id))); }
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")); }
//rezervace se bude zadavat v planu terminu //[HttpPost] public ActionResult Add(int termId) { try { Reservation r = new Reservation(); ReservationDao rDao = new ReservationDao(); TermDao tDao = new TermDao(); UserDao uDao = new UserDao(); r.Term = tDao.GetById(termId); r.User = uDao.GetByLogin(User.Identity.Name); r.ReservationTime = DateTime.Now; if (tDao.GetActualCapacity(r.Term) > 0 && rDao.ReservationExist(r.Term, r.User) == false) { rDao.Create(r); TempData["succes"] = "Termín úspěšně rezervován."; } else if (tDao.GetActualCapacity(r.Term) <= 0) { TempData["warning"] = "Termín je již plně obsazen."; } else if (rDao.ReservationExist(r.Term, r.User) != false) { TempData["warning"] = "Termín již máte rezervovaný."; } } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index", "Term")); }