public ActionResult Search(string phrase) { TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.SearchTours(phrase); return(View("Index", tours)); }
public ActionResult Detail(long id) { var tour = new TourDao().ViewDetail(id); ViewBag.Tour = new TourDao().ViewDetail(tour.ID); return(View(tour)); }
///////////////////END SEARCH/////////////////// public ActionResult Detail(int id) { TourDao bookDao = new TourDao(); Tour b = bookDao.GetById(id); return(View(b)); }
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")); }
public ActionResult RezervaceDetailSide(int id) { TourDao bookDao = new TourDao(); Tour b = bookDao.GetById(id); return(View(b)); }
// GET: Tour public ActionResult Index() { List <Tour> tLists = TourDao.getTourList(); ViewData["TourList"] = tLists; return(View()); }
// GET: Admin/Tour public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var dao = new TourDao(); var model = dao.ListAllPaging(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View(model)); }
public ActionResult SearchPrice(int hi) { int totalBooks; TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.SearchByPrice(hi); return(View("Index", tours)); }
///////////////////SEARCH///////////////////// public ActionResult Category(int id) { IList <Tour> tours = new TourDao().GetToursInCategoryId(id); ViewBag.Categories = new DestinationDao().GetAll(); return(View("Index", tours)); }
public ActionResult Add(Tour tour, HttpPostedFileBase picture, int categoryId) { DestinationDao destinationDao = new DestinationDao(); IList <Destination> destinations = destinationDao.GetAll(); ViewBag.Categories = destinations; if (ModelState.IsValid) { if (picture != null) { if (picture.ContentType == "image/jpeg" || picture.ContentType == "image/png") { Image image = Image.FromStream(picture.InputStream); Guid guid = Guid.NewGuid(); string imageName = guid.ToString() + ".jpg"; Image smallImage = ImageHelper.ScaleImage(image, 1200, 1200); Bitmap b = new Bitmap(smallImage); b.Save(Server.MapPath("~/uploads/book/" + imageName), ImageFormat.Jpeg); smallImage.Dispose(); b.Dispose(); tour.ImageName = imageName; } } Destination destination = destinationDao.GetById(categoryId); tour.Destination = destination; if (tour.CurrentCapacity == null) { tour.CurrentCapacity = 0; } if (tour.Priority == null) { tour.Priority = 0; } TourDao tourDao = new TourDao(); tourDao.Create(tour); TempData["message-success"] = "Zajezd byl uspesne pridan"; } else { return(View("Create", tour)); } return(RedirectToAction("Index")); }
public ActionResult ReservationSection(int id) { TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.GetAll(); ViewBag.Rezervace = tours; ReservationDao reservationDao = new ReservationDao(); Reservation reservation = reservationDao.GetById(id); return(View(reservation)); }
public ActionResult AssignLeader(int leaderId, int tourRef) { string msg = ""; Leader l = LeaderDao.getLeaderById(leaderId); Tour t = TourDao.getTourById(tourRef); bool available = true; List <Tour> assignments = TourDao.getToursByLeaderId(leaderId); foreach (Tour task in assignments) { if (t.departureDate < task.departureDate) { if ((task.departureDate - t.departureDate).TotalDays > t.numOfDays) { available = true; } else { available = false; break; } } if (t.departureDate >= task.departureDate) { if ((t.departureDate - task.departureDate).TotalDays > task.numOfDays) { available = true; } else { available = false; break; } } } if (available) { if (l.checkDestination(t.destination)) { TourDao.UpdateLeader(leaderId, tourRef); msg = "Successfully assigned."; } else { msg = "Destination does not match Tour Leader's preference."; } } else { msg = "Tour Leader already has conflicting assignments."; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(int id) { TourDao bookDao = new TourDao(); DestinationDao bookCategoryDao = new DestinationDao(); Tour b = bookDao.GetById(id); ViewBag.Categories = bookCategoryDao.GetAll(); return(View(b)); }
public ActionResult RenderSide2() { /** * Render Side for Detail Index - Top Tour */ int totalBlogs; TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.GetToursPaged(1, 1, out totalBlogs); return(View(tours)); }
public ActionResult Assign() { List <Tour> tLists = TourDao.getTourList(); ViewData["TourList"] = tLists; List <Leader> leaders = LeaderDao.getAllLeaders(); ViewData["LeaderList"] = leaders; return(View()); }
public ActionResult Search(string phrase) { TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.SearchTours(phrase); KnihovnaUser user = new KnihovnaUserDao().GetByLogin(User.Identity.Name); if (user.Role.Identificator != "admin") { return(View("IndexCtenar", tours)); } return(View("Index", tours)); }
// GET: Books public ActionResult Index(int?page) { int itemsOnPage = 5; int pg = page.HasValue ? page.Value : 1; int totalBooks; TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.GetToursPaged(itemsOnPage, pg, out totalBooks); foreach (Tour tour in tours) { if (tour.StartDate.CompareTo(DateTime.Now) > 0) { if (tour.CurrentCapacity == tour.Capacity) { tour.Status = "obsazeno"; } else { tour.Status = "volno"; } } int result = DateTime.Compare(DateTime.Now, tour.EndDate); if (result > 0) { //uskutecneno tour.Status = "uskutecneno"; tours.Remove(tour); break; } if (tour.StartDate.CompareTo(DateTime.Now) < 0 && tour.EndDate.CompareTo(DateTime.Now) > 0) { tour.Status = "kona_se"; } } //List<Tour> tours2 = (from Tour t in tours orderby t.Priority descending select t).ToList(); ViewBag.Pages = (int)Math.Ceiling((double)totalBooks / (double)itemsOnPage); ViewBag.CurrentPage = pg; ViewBag.Categories = new DestinationDao().GetAll(); KnihovnaUser user = new KnihovnaUserDao().GetByLogin(User.Identity.Name); if (user.Role.Identificator != "admin") { return(View("IndexCtenar", tours)); //klasicky pohled navstevnika } return(View(tours)); //admin index }
public ActionResult SearchPrice(int hi) { int totalBooks; TourDao tourDao = new TourDao(); IList <Tour> tours = tourDao.SearchByPrice(hi); KnihovnaUser user = new KnihovnaUserDao().GetByLogin(User.Identity.Name); if (user.Role.Identificator != "admin") { return(View("IndexCtenar", tours)); } return(View("Index", tours)); }
public ActionResult ReservationSection(int id) { TourDao tDao = new TourDao(); IList <Tour> t = new List <Tour>(); t.Add(tDao.GetById(id)); ViewBag.Tour = t; ReservationDao reservationDao = new ReservationDao(); Reservation reservation = reservationDao.GetById(id); return(View(reservation)); }
///////////////////SEARCH///////////////////// public ActionResult Category(int id) { IList <Tour> tours = new TourDao().GetToursInCategoryId(id); ViewBag.Categories = new DestinationDao().GetAll(); KnihovnaUser user = new KnihovnaUserDao().GetByLogin(User.Identity.Name); if (user.Role.Identificator != "admin") { return(View("IndexCtenar", tours)); } return(View("Index", tours)); }
public ActionResult Update(Tour tour, HttpPostedFileBase picture, int categoryId) { try { TourDao bookDao = new TourDao(); DestinationDao bookCategoryDao = new DestinationDao(); Destination bookCategory = bookCategoryDao.GetById(categoryId); tour.Destination = bookCategory; if (picture != null) { if (picture.ContentType == "image/jpeg" || picture.ContentType == "image/png") { Image image = Image.FromStream(picture.InputStream); Guid guid = Guid.NewGuid(); string imageName = guid.ToString() + ".jpg"; //picture.SaveAs(Server.MapPath("~/uploads/tour/" + picture.FileName)); Image smallImage = ImageHelper.ScaleImage(image, 1200, 1200); Bitmap b = new Bitmap(smallImage); b.Save(Server.MapPath("~/uploads/book/" + imageName), ImageFormat.Jpeg); smallImage.Dispose(); b.Dispose(); //smazat stary soubor System.IO.File.Delete(Server.MapPath("~/uploads/book/" + tour.ImageName)); tour.ImageName = imageName; } } bookDao.Update(tour); TempData["message-success"] = "Zajezd " + tour.Name + " byl upraven"; } catch (Exception) { throw; } return(RedirectToAction("Index", "Tours")); }
public ActionResult AddReservation(Reservation reservation, int tourId) { ReservationDao reservationDao = new ReservationDao(); RandomGenerator generator = new RandomGenerator(); string validationNumber = generator.RandomPassword(); reservation.ValidationNumber = validationNumber; reservation.Status = "nezaplaceno"; reservation.KnihovnaUser = new KnihovnaUserDao().GetByLogin(User.Identity.Name); if (ModelState.IsValid) { TourDao tourDao = new TourDao(); Tour tour = tourDao.GetById(tourId); reservation.Tour = tour; int result = DateTime.Compare(DateTime.Now, tour.StartDate); if (tour.CurrentCapacity < tour.Capacity && result < 0) { reservationDao.Create(reservation); tour.CurrentCapacity++; tourDao.Update(tour); reservationDao.Update(reservation); TempData["message-success"] = "Vase rezervace byla uspesne odeslana, prosim ulozte si nasledujici kod: " + validationNumber; } else { TempData["message-danger"] = "Je nam lito ale neni mozne provest rezervaci"; } } else { return(RedirectToAction("Detail", "Tours", new { id = tourId })); } return(RedirectToAction("Detail", "Tours", new { id = tourId })); //presmerovani }
public ActionResult Edit(Tour tour) { if (ModelState.IsValid) { var dao = new TourDao(); var result = dao.CapNhat(tour); if (result) { return(RedirectToAction("Index", "Tour")); } else { ModelState.AddModelError("", "Cập nhật tour không thành công !"); } } return(View("Index")); }
public ActionResult Create(Tour tour) { if (ModelState.IsValid) { var dao = new TourDao(); long id = dao.Them(tour); if (id > 0) { return(RedirectToAction("Index", "Tour")); } else { ModelState.AddModelError("", "Thêm tour không thành công !"); } } return(View("Index")); }
public ActionResult DeleteReservation(int id) { try { ReservationDao reservationDao = new ReservationDao(); Reservation reservation = reservationDao.GetById(id); TourDao tourDao = new TourDao(); Tour tour = tourDao.GetById(reservation.Tour.Id); tour.CurrentCapacity--; tourDao.Update(tour); reservationDao.Delete(reservation); TempData["message-success"] = "Rezervace " + reservation.ValidationNumber + " byla uspesne smazana z databazi"; } catch (Exception e) { throw; } return(RedirectToAction("Rezervace", "Tours")); }
public ActionResult ChangeStatus(int id, Boolean zrusit, Boolean vratit) { try { ReservationDao reservationDao = new ReservationDao(); Reservation reservation = reservationDao.GetById(id); TourDao tourDao = new TourDao(); Tour tour = tourDao.GetById(reservation.Tour.Id); if (zrusit) { if (vratit) { int result = DateTime.Compare(DateTime.Now, tour.StartDate); if (tour.CurrentCapacity < tour.Capacity && result < 0) { reservation.Status = "nezaplaceno"; tour.CurrentCapacity++; tourDao.Update(tour); reservationDao.Update(reservation); TempData["message-success"] = "Status rezervace " + reservation.ValidationNumber + " byl zmenen"; } else { TempData["message-danger"] = "Je nam lito ale neni mozne vratit rezervaci. Nedostatek mist nebo je zajezd uz zahajen."; } } else { reservation.Status = "zruseno"; tour.CurrentCapacity--; tourDao.Update(tour); reservationDao.Update(reservation); TempData["message-success"] = "Status rezervace " + reservation.ValidationNumber + " byl zmenen"; } } else { if (reservation.Status == "nezaplaceno") { reservation.Status = "zaplaceno"; } else { reservation.Status = "nezaplaceno"; } reservationDao.Update(reservation); TempData["message-success"] = "Status rezervace " + reservation.ValidationNumber + " byl zmenen"; } } catch (Exception e) { throw; } return(RedirectToAction("Rezervace", "Tours")); }
public ActionResult Edit(int id) { var tour = new TourDao().ViewDetail(id); return(View(tour)); }