Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 //
 // GET: /Event/Delete/5
 public ActionResult Delete(string tourid, DateTime tourdate)
 {
     BTourGuideOp tourOp = new BTourGuideOp();
     List<AEvent> events = tourOp.GetEvents();
     AEvent tourEvent = events.SingleOrDefault<AEvent>(x => x.TourID == tourid && x.TourDate == tourdate);
     if (tourEvent == null)
     {
         return HttpNotFound();
     }
     return View(tourEvent);
 }
Ejemplo n.º 3
0
 public List<SelectListItem> GetTourDates(TourName tourName)
 {
     BTourGuideOp op = new BTourGuideOp();
     List<AEvent> tourEvents = op.GetEvents(tourName.Name);
     List<SelectListItem> tourDates = new List<SelectListItem>();
     foreach (AEvent tourEvent in tourEvents)
     {
         tourDates.Add(new SelectListItem { Text = tourEvent.TourDate.ToString(), Value = tourEvent.TourDate.ToString() });
     }
     return tourDates;
 }
Ejemplo n.º 4
0
 public static List<SelectListItem> CreateTourDateList(string tourName)
 {
     // Creating a dropdown list for TourDates:
     List<SelectListItem> tourDates = new List<SelectListItem>();
     BTourGuideOp tourOp = new BTourGuideOp();
     List<AEvent> events = tourOp.GetEvents(tourName);
     foreach (AEvent tourEvent in events)
     {
         tourDates.Add(new SelectListItem { Text = tourEvent.TourDate.ToString(), Value = tourEvent.TourDate.ToString() });
     }
     return tourDates;
 }
Ejemplo n.º 5
0
 public ActionResult Date()
 {
     BTourGuideOp tourOp = new BTourGuideOp();
     List<AEvent> tourEvents = tourOp.GetEvents();
     List<string> dates = new List<string>();
     foreach (AEvent tourEvent in tourEvents)
     {
         if (!dates.Contains(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(tourEvent.TourDate.Month)))
         {
             dates.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(tourEvent.TourDate.Month));
         }
     }
     ViewBag.dates = dates;
     return View(tourEvents);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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);
     }
 }
Ejemplo n.º 9
0
 //
 // GET: /Event/Details/5
 public ActionResult Details(string tourid, DateTime tourdate)
 {
     BTourGuideOp tourOp = new BTourGuideOp();
     List<AEvent> events = tourOp.GetEvents();
     AEvent tourEvent = events.Single<AEvent>(x => x.TourID == tourid && x.TourDate == tourdate);
     return View(tourEvent);
 }
Ejemplo n.º 10
0
 //
 // GET: /Event/
 public ActionResult Index()
 {
     BTourGuideOp tourOp = new BTourGuideOp();
     List<AEvent> events = tourOp.GetEvents();
     return View(events);
 }
Ejemplo n.º 11
0
 public ActionResult Guide()
 {
     BTourGuideOp tourOp = new BTourGuideOp();
     List<AEvent> tourEvents = tourOp.GetEvents();
     List<string> guides = new List<string>();
     foreach (AEvent tourEvent in tourEvents)
     {
         if (!guides.Contains(tourEvent.TourGuide))
         {
             guides.Add(tourEvent.TourGuide);
         }
     }
     ViewBag.guides = guides;
     return View(tourEvents);
 }
Ejemplo n.º 12
0
 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);
 }