Exemplo n.º 1
0
        public IActionResult Index()
        {
            User user = new User();

            user = authProvider.GetCurrentUser();

            Event eventItem = new Event();

            eventItem.Podcast       = new Podcast();
            eventItem.Podcast.Genre = new Genre();


            SearchViewModel model = new SearchViewModel
            {
                Event         = eventItem,
                VenueList     = GetVenueList(),
                GenreList     = GetGenreList(),
                TicketList    = GetTicketList(),
                PodcastList   = GetPodcastList(),
                TimeOfDayList = GetTimeOfDay(),
                User          = user,
                UserFav       = new Dictionary <int, bool>()
            };

            model.EventList = eventSqlDal.GetFutureEvents(eventItem, user);


            foreach (Event item in model.EventList)
            {
                item.Venue         = venueSqlDal.GetVenue(item.VenueID);
                item.Podcast       = podcastSqlDal.GetPodcast(item.PodcastID);
                item.Podcast.Genre = genreSqlDal.GetGenreEventID(item.EventID);
                item.Ticket        = ticketSqlDal.GetTicket(item.TicketLevel);
            }

            model.ArchivedEventList = eventSqlDal.GetPastEvents(eventItem, user);
            foreach (Event item in model.ArchivedEventList)
            {
                item.Venue         = venueSqlDal.GetVenue(item.VenueID);
                item.Podcast       = podcastSqlDal.GetPodcast(item.PodcastID);
                item.Podcast.Genre = genreSqlDal.GetGenreEventID(item.EventID);
                item.Ticket        = ticketSqlDal.GetTicket(item.TicketLevel);
            }

            model.EventListByDay = model.EventList
                                   .GroupBy(p => p.Beginning.Date)
                                   .Select(g => g.ToList())
                                   .ToList();

            List <Event> userEvents = eventSqlDal.GetUserEvents(user);

            foreach (Event item in userEvents)
            {
                model.UserFav.Add(item.EventID, true);
            }

            return(View(model));
        }
        public IActionResult Index()
        {
            List <Event> eventList = eventSqlDal.GetAllEvents();

            eventList.ForEach(e =>
            {
                e.Podcast       = podcastDal.GetPodcast(e.PodcastID);
                e.Venue         = venueSqlDal.GetVenue(e.VenueID);
                e.Podcast.Genre = genreSqlDal.GetGenre(e.Podcast.GenreID);
                e.Ticket        = ticketSqlDal.GetTicket(e.TicketLevel);
            });



            return(View(eventList));
        }
        public ActionResult EncodeICal(int eventID)
        {
            Event eventItem = eventSqlDal.GetEvent(eventID);

            eventItem.Venue = venueSqlDal.GetVenue(eventItem.VenueID);

            string    downloadFileName  = "PodfestMidWestEvent.ics";
            ICalendar ical              = new ICalendar();
            var       icalStringbuilder = new StringBuilder();

            icalStringbuilder.AppendLine("BEGIN:VCALENDAR");
            icalStringbuilder.AppendLine("PRODID:-//PodfestMidwest//EN");
            icalStringbuilder.AppendLine("VERSION:2.0");
            icalStringbuilder.AppendLine("BEGIN:VEVENT");
            icalStringbuilder.AppendLine("SUMMARY;LANGUAGE=en-us:" + eventItem.EventName);
            icalStringbuilder.AppendLine("CLASS:PUBLIC");
            icalStringbuilder.AppendLine(string.Format("CREATED:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));
            icalStringbuilder.AppendLine("DESCRIPTION:" + eventItem.DescriptionCopy);
            icalStringbuilder.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", eventItem.Beginning));
            icalStringbuilder.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", eventItem.Ending));
            icalStringbuilder.AppendLine("SEQUENCE:0");
            icalStringbuilder.AppendLine("UID:" + Guid.NewGuid());
            icalStringbuilder.AppendLine(
                string.Format(
                    "LOCATION:{0}\\, {1}\\, {2}\\, {3} {4}",
                    eventItem.Venue.DisplayName,
                    eventItem.Venue.Address1,
                    eventItem.Venue.City,
                    eventItem.Venue.State,
                    eventItem.Venue.ZipCode).Trim());
            icalStringbuilder.AppendLine("END:VEVENT");
            icalStringbuilder.AppendLine("END:VCALENDAR");

            var bytes = Encoding.UTF8.GetBytes(icalStringbuilder.ToString());

            return(this.File(bytes, "text/calendar", downloadFileName));
        }