Пример #1
0
        public IActionResult SearchEvents(SearchViewModel model)
        {
            User user = authProvider.GetCurrentUser();

            model.User      = user;
            model.EventList = eventSqlDal.Search(model.Event, user);
            model.UserFav   = new Dictionary <int, bool>();

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

            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 string GenerateGoogleCal(int eventID)
        //    {
        //        Event eventItem = eventSqlDal.GetEvent(eventID);
        //        eventItem.Podcast = podcastDal.GetPodcast(eventItem.PodcastID);
        //        eventItem.Venue = venueSqlDal.GetVenue(eventItem.VenueID);
        //        eventItem.Podcast.Genre = genreSqlDal.GetGenre(eventItem.Podcast.GenreID);
        //        eventItem.Ticket = ticketSqlDal.GetTicket(eventItem.TicketLevel);
        //        eventItem.GoogleURL = GenerateGoogleCal(eventItem.EventID);

        //        string googleURLstart = "https://calendar.google.com/calendar/render?action=TEMPLATE&text=";
        //        string eventName = eventItem.EventName;
        //        string googledates = @"&dates=";
        //        string beginning = eventItem.Beginning.ToString("yyyyMMddTHHmmssZ");
        //        string googelSlash = @"/";
        //        string ending = eventItem.Ending.ToString("yyyyMMddTHHmmssZ");
        //        string googleDetails = @"&details = For + details,+link + here:+";
        //        string url = (eventItem.Podcast.URL == null) ? "" : eventItem.Podcast.URL;
        //        string googleLocation = "&location = ";
        //        string venue = System.Web.HttpUtility.UrlEncode(eventItem.Venue.DisplayName + "," +
        //                eventItem.Venue.Address1 + "," +
        //                eventItem.Venue.City + "," +
        //                eventItem.Venue.State + "," +
        //                eventItem.Venue.ZipCode);
        //        string googleOut = @"& sf = true & output = xml";
        //        string googleURL = googleURLstart + eventName + googledates + beginning + googelSlash + ending + googleDetails + url + googleLocation + venue + googleOut;
        //        return Uri.EscapeUriString(googleURL);

        //    }

        //}

        //https://calendar.google.com/calendar/render?action=TEMPLATE&text=Birthday&dates=20180201T090000/20180201T180000&sprop=&sprop=name:
        //    https://www.google.com/calendar   +301+Park+Ave+,+New+York,+NY+10022&sf=true&output=xml


        private Event PopulateEventDetails(int id)

        {
            Event eventItem = eventSqlDal.GetEvent(id);



            if (eventItem.PodcastID != null)
            {
                eventItem.Podcast       = podcastDal.GetPodcast(eventItem.PodcastID);
                eventItem.Podcast.Genre = genreSqlDal.GetGenre(eventItem.Podcast.GenreID);
            }

            if (eventItem.VenueID != null)
            {
                eventItem.Venue = venueSqlDal.GetVenue(eventItem.VenueID);
            }

            if (eventItem.TicketLevel != null)
            {
                eventItem.Ticket = ticketSqlDal.GetTicket(eventItem.TicketLevel);
            }

            return(eventItem);
        }