public ActionResult Create(AEvent tourEvent, string TourNameOptions) { try { if (ModelState.IsValid) { BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); ATour tour = tours.Single(x => x.TourName == TourNameOptions); tourEvent.TourID = tour.TourID; tourEvent.TourName = TourNameOptions; tourOp.AddEvent(tourEvent); return RedirectToAction("Index"); } else { ViewBag.TourNameOptions = Lists.CreateTourList(); return View(tourEvent); } } catch(Exception e) { TempData["CreateException"] = "Error in event creation: " + e.Message; return View(); } }
public List<EventDetails> GetUpcomingEvents() { // prevent the browser from caching WCF JSON responses HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoStore(); //--------------------------------------------------- BTourGuideOp op = new BTourGuideOp(); List<EventDetails> tourEvents = new List<EventDetails>(); List<AEvent> events = op.GetEvents(); List<ATour> tours = op.GetTours(); foreach (AEvent tourEvent in events) { EventDetails eventDetails = new EventDetails(); if (tourEvent.TourDate > DateTime.Now) { if (tourEvents.Count > 2) break; eventDetails.EventInfo = tourEvent; foreach(ATour tour in tours) { if (tour.TourID == tourEvent.TourID) { eventDetails.TourInfo = tour; } } tourEvents.Add(eventDetails); } } return tourEvents; }
public static List<SelectListItem> CreateTourList() { // Creating a dropdown list for TourNames: List<SelectListItem> tourNames = new List<SelectListItem>(); BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); foreach (ATour tour in tours) { tourNames.Add(new SelectListItem { Text = tour.TourName, Value = tour.TourName }); } return tourNames; }
public ActionResult Category() { BTourGuideOp tourOp = new BTourGuideOp(); List<AEvent> tourEvents = tourOp.GetEvents(); List<ATour> tours = tourOp.GetTours(); List<string> categories = new List<string>(); foreach (ATour tour in tours) { if (!categories.Contains(tour.TourCategory)) { categories.Add(tour.TourCategory); } } ViewBag.categories = categories; return View(tourEvents); }
public ActionResult Area() { BTourGuideOp tourOp = new BTourGuideOp(); List<AEvent> tourEvents = tourOp.GetEvents(); List<ATour> tours = tourOp.GetTours(); List<string> areas = new List<string>(); foreach (ATour tour in tours) { if (!areas.Contains(tour.TourArea)) { areas.Add(tour.TourArea); } } ViewBag.areas = areas; return View(tourEvents); }
public ActionResult Create(AReg reg, string TourNameOptions, string UsernameOptions, string TourDateOptions) { try { if (ModelState.IsValid) { BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); ATour tour = tours.Single(x => x.TourName == TourNameOptions); reg.TourID = tour.TourID; List<AUser> users = tourOp.GetUsers(); AUser user = users.Single(x => x.Username == UsernameOptions); reg.UserID = user.UserID; List<AEvent> events = tourOp.GetEvents(); AEvent tourEvent = events.Single(x => x.TourName == TourNameOptions && x.TourDate.ToString() == TourDateOptions.ToString()); reg.TourDate = tourEvent.TourDate; tourOp.AddReg(reg); return RedirectToAction("Index"); } else { // Saving the dropdown values selected by user: List<SelectListItem> tourList = Lists.CreateTourList(); ViewBag.TourNameOptions = tourList; // The initial TourDateOptions ddl fits the first tour already selected by user: string tourName = TourNameOptions; ViewBag.TourDateOptions = Lists.CreateTourDateList(tourName); //The tourDates dropdown list options change based on the tourName choice. This is done with AJAX via query using // a web service. ViewBag.UsernameOptions = Lists.CreateUserList(); return View(reg); } } catch(Exception e) { TempData["CreateException"] = "Error in Reg creation: " + e.Message; return View(reg); } }
// // GET: /Admin/ public ActionResult Index() { BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); return View(tours); }
// // GET: /Tour/Edit/5 public ActionResult Edit(string id) { BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); ATour tour = tours.Single<ATour>(x => x.TourID == id); return View(tour); }
// // GET: /Tour/Delete/5 public ActionResult Delete(string id) { BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); ATour tour = tours.SingleOrDefault<ATour>(x => x.TourID == id); if (tour == null) { return HttpNotFound(); } return View(tour); }
public ActionResult Location() { BTourGuideOp tourOp = new BTourGuideOp(); List<AEvent> tourEvents = tourOp.GetEvents(); List<ATour> tours = tourOp.GetTours(); List<string> locations = new List<string>(); foreach(ATour tour in tours) { if (!locations.Contains(tour.TourLocation)) { locations.Add(tour.TourLocation); } } ViewBag.locations = locations; return View(tourEvents); }
public ActionResult Index(string id) { if (id != null && id != "" && id != "undefined") // The user typed a keyword { ViewBag.keyword = id; BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(id); if (tours.Count > 0) { return View(tours); } else { TempData["SearchMessage"] = "No tours that match your keyword were found"; TempData["SearchTextbox"] = id; return RedirectToAction("Index", "Home"); } } else // The search textbox is empty / the user clicked on "Tours" { BTourGuideOp tourOp = new BTourGuideOp(); List<ATour> tours = tourOp.GetTours(); return View(tours); //return RedirectToAction("AdvancedSearch"); } }