public IActionResult Index([FromServices] EventsContext eventsContext, [FromServices] IOptions <ApplicationSettings> appSettings)
        {
            var upcomingEvents = Enumerable.Empty <Event>();

            UpcomingEventsViewModel viewModel = new UpcomingEventsViewModel
            {
                Events = upcomingEvents
            };

            return(View(viewModel));
        }
示例#2
0
        public IActionResult Index([FromServices] EventsContext eventsContext, [FromServices] IOptions <ApplicationSettings> appSettings)
        {
            var upcomingEvents = eventsContext.Events
                                 .Where(e => e.StartTime >= DateTime.Today)
                                 .OrderBy(e => e.StartTime)
                                 .Take(appSettings.Value.LatestEventCount);

            UpcomingEventsViewModel viewModel = new UpcomingEventsViewModel
            {
                Events = upcomingEvents
            };

            return(View(viewModel));
        }
示例#3
0
        // GET: UpcomingEvent
        public ActionResult Index()
        {
            Context _context = new Context();
            UpcomingEventsViewModel eventList = new UpcomingEventsViewModel();

            eventList.UpcomingEvents = (from aw in _context.ArtWork
                                        join ar in _context.Artist
                                        on aw.ArtistId equals ar.ArtistId
                                        join ars in _context.ArtShow
                                        on aw.ArtWorkId equals ars.ArtWorkId
                                        select new Events
            {
                ShowName = ars.ShowName,
                ShowLocation = ars.ShowLocation,
                ShowDate = ars.ShowDate,
                Agents = ars.Agents,
                ArtistName = ar.Name
            }).ToList();
            return(View(eventList));
        }
        protected override void OnReady(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (!_alreadyNavigatedTo)
            {
                IDictionary <string, string> parameters = this.NavigationContext.QueryString;

                string defaultPanoramaItem;

                if (!parameters.TryGetValue("defaultPanoramaItem", out defaultPanoramaItem))
                {
                    defaultPanoramaItem = "PanHome";
                }
                var defaultItem = PanMain.FindName(defaultPanoramaItem) as PanoramaItem;
                PanMain.DefaultItem = defaultItem;
                UpdateSelectedPanoramaItem(defaultItem);
                _alreadyNavigatedTo = true;
            }
            else
            {
                //quick hack until i can figure out why the list isn't loading on back button
                var oldActivitiesVM = PanActivity.DataContext as ActivitiesViewModel;
                var newActivitiesVM = new ActivitiesViewModel();
                if (oldActivitiesVM.LoadStarted)
                {
                    newActivitiesVM.Load(oldActivitiesVM.AllLoaded);
                }
                PanActivity.DataContext = newActivitiesVM;

                var oldUpcomingEventsVM = PanUpcoming.DataContext as UpcomingEventsViewModel;
                var newUpcomingEventsVM = new UpcomingEventsViewModel();
                if (oldUpcomingEventsVM.LoadStarted)
                {
                    newUpcomingEventsVM.Load(oldUpcomingEventsVM.AllLoaded);
                }
                PanUpcoming.DataContext = newUpcomingEventsVM;
            }
        }
示例#5
0
        public ActionResult Index()
        {
            UpcomingEventsViewModel viewModel = new UpcomingEventsViewModel();

            return(View(viewModel));
        }
示例#6
0
        // GET: /Calendar/UpcomingEvents
        public async Task <ActionResult> UpcomingEvents()
        {
            const int MaxEventsPerCalendar = 20;
            const int MaxEventsOverall     = 50;

            var model = new UpcomingEventsViewModel();

            var credential = await GetCredentialForApiAsync();

            var initializer = new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "ASP.NET MVC5 Calendar Sample",
            };
            var service = new CalendarService(initializer);

            // Fetch the list of calendars.
            var calendars = await service.CalendarList.List().ExecuteAsync();

            // Fetch some events from each calendar.
            var fetchTasks = new List <Task <Google.Apis.Calendar.v3.Data.Events> >(calendars.Items.Count);

            foreach (var calendar in calendars.Items)
            {
                var request = service.Events.List(calendar.Id);
                request.MaxResults   = MaxEventsPerCalendar;
                request.SingleEvents = true;
                request.TimeMin      = DateTime.Now;
                fetchTasks.Add(request.ExecuteAsync());
            }
            var fetchResults = await Task.WhenAll(fetchTasks);

            // Sort the events and put them in the model.
            var upcomingEvents = from result in fetchResults
                                 from evt in result.Items
                                 where evt.Start != null
                                 let date = evt.Start.DateTime.HasValue ?
                                            evt.Start.DateTime.Value.Date :
                                            DateTime.ParseExact(evt.Start.Date, "yyyy-MM-dd", null)
                                            let sortKey = evt.Start.DateTimeRaw ?? evt.Start.Date
                                                          orderby sortKey
                                                          select new { evt, date };
            var eventsByDate = from result in upcomingEvents.Take(MaxEventsOverall)
                               group result.evt by result.date into g
                               orderby g.Key
                               select g;

            var eventGroups = new List <CalendarEventGroup>();

            foreach (var grouping in eventsByDate)
            {
                eventGroups.Add(new CalendarEventGroup
                {
                    GroupTitle = grouping.Key.ToLongDateString(),
                    Events     = grouping,
                });
            }

            model.EventGroups = eventGroups;
            return(View(model));
        }
示例#7
0
        // this is change for testing git
        // test number2


        // GET: /Calendar/UpcomingEvents
        public ActionResult Event()
        {
            var            model  = new UpcomingEventsViewModel();
            var            folder = System.Web.HttpContext.Current.Server.MapPath("~/Content/MyGoogleStorage");
            UserCredential credential;
            var            path = Server.MapPath("~/App_Data/client_secret.json");

            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    new[] { CalendarService.Scope.CalendarReadonly },
                    "user", CancellationToken.None,
                    new FileDataStore(folder)).Result;
            }

            var initializer = new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "lcsc-points-system",
            };
            var service     = new CalendarService(initializer);
            var eventGroups = new List <CalendarEventGroup>();

            string[] calendarIDs = new string[6] {
                "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"
            };
            //in order of "Academics", "Student Activities", "Warrior Athletics", "Entertainment", "Residence Life","Campus Rec"
            string[] calidentity = new string[6] {
                "Academics", "Student Activities", "Warrior Athletics", "Entertainment", "Residence Life", "Campus Rec"
            };
            string[] calendarpoints = new string[6] {
                "700points", "600point", "500points", "400points", "300points", "200points"
            };
            //this calendarpoints are string because I was lazy enough to do some work on Event.cshtml file.
            //if we want to change back to int, then we need to change to int[]  new int[6],
            // and go to CalendarEventGroup.cs in the model, change "public string points" to "public int points"
            for (int i = 0; i < calendarIDs.Length; i++)
            {
                EventsResource.ListRequest request = service.Events.List(calendarIDs[i]);
                request.TimeMin      = DateTime.Now;
                request.ShowDeleted  = false;
                request.SingleEvents = true;
                //request.MaxResults = 10;
                request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
                Events events = request.Execute();

                if (events.Items != null && events.Items.Count > 0)
                {
                    foreach (var eventItem in events.Items)
                    {
                        string   when    = eventItem.Start.DateTime.ToString();
                        string   allsum  = eventItem.Summary.ToString();
                        string   htmlink = eventItem.HtmlLink;
                        DateTime actualschedule;
                        if (String.IsNullOrEmpty(when))
                        {
                            when           = eventItem.Start.Date;
                            actualschedule = Convert.ToDateTime(when);
                        }
                        else
                        {
                            actualschedule = Convert.ToDateTime(when);
                        }


                        eventGroups.Add(new CalendarEventGroup
                        {
                            Events       = allsum,
                            startdate    = actualschedule,
                            points       = calendarpoints[i],
                            fromcalendar = calidentity[i],
                            thelink      = htmlink,
                        });
                    }
                }
            }
            eventGroups.Sort((x, y) => x.startdate.CompareTo(y.startdate));
            model.EventGroups = eventGroups;
            return(View(model));
        }
示例#8
0
        //private readonly IDataStore dataStore = new FileDataStore(GoogleWebAuthorizationBroker.Folder);

        //private async Task<UserCredential> GetCredentialForApiAsync()
        //{
        //    var initializer = new GoogleAuthorizationCodeFlow.Initializer
        //    {
        //        ClientSecrets = new ClientSecrets
        //        {
        //            ClientId = MyClientSecrets.ClientId,
        //            ClientSecret = MyClientSecrets.ClientSecret,
        //        },
        //        Scopes = CalendarScopes.Scopes,
        //    };
        //    var flow = new GoogleAuthorizationCodeFlow(initializer);

        //    var identity = await HttpContext.GetOwinContext().Authentication.GetExternalIdentityAsync(
        //        DefaultAuthenticationTypes.ApplicationCookie);
        //    var userId = identity.FindFirstValue(MyClaimTypes.GoogleUserId);

        //    var token = await dataStore.GetAsync<TokenResponse>(userId);
        //    return new UserCredential(flow, userId, token);
        //}


        public ActionResult UpcomingEvents()
        {
            UserCredential credential;
            string         credPath1 = @"~\Documents\credentials.json";

            using (var stream =
                       new FileStream(Server.MapPath(credPath1), FileMode.Open, FileAccess.ReadWrite))
            {
                string credPath = Server.MapPath(@"~\Documents\token.json");
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    CalendarScopes.Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, false)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }
            // Create Drive API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            //const int MaxEventsPerCalendar = 20;
            //const int MaxEventsOverall = 50;

            var model = new UpcomingEventsViewModel();

            // Fetch the list of calendars.
            //var calendars = service.CalendarList.List().Execute();

            //Fetch some events from each calendar.
            //var fetchTasks = new List<Task<Google.Apis.Calendar.v3.Data.Events>>(calendars.Items.Count);
            //foreach (var calendar in calendars.Items)
            //{
            //    var request = service.Events.List(calendar.Id);
            //    request.MaxResults = MaxEventsPerCalendar;
            //    request.SingleEvents = true;
            //    request.TimeMin = DateTime.Now;
            //    fetchTasks.Add(request.Execute());
            //}
            //var fetchResults = fetchTasks;
            //Sort the events and put them in the model.
            //var upcomingEvents = from result in fetchResults
            //                     from evt in result.Items
            //                     where evt.Start != null
            //                     let date = evt.Start.DateTime.HasValue ?
            //                         evt.Start.DateTime.Value.Date :
            //                         DateTime.ParseExact(evt.Start.Date, "yyyy-MM-dd", null)
            //                     let sortKey = evt.Start.DateTimeRaw ?? evt.Start.Date
            //                     orderby sortKey
            //                     select new { evt, date };
            //var eventsByDate = from result in upcomingEvents.Take(MaxEventsOverall)
            //                   group result.evt by result.date into g
            //                   orderby g.Key
            //                   select g;

            //var eventGroups = new List<CalendarEventGroup>();
            //foreach (var grouping in eventsByDate)
            //{
            //    eventGroups.Add(new CalendarEventGroup
            //    {
            //        GroupTitle = grouping.Key.ToLongDateString(),
            //        Events = grouping,
            //    });
            //}

            // model.EventGroups = eventGroups;
            return(View(model));
        }
示例#9
0
        public ActionResult AddEvent(UpcomingEventsViewModel model)
        {
            UserCredential credential;
            string         credPath1 = @"~\Documents\credentials.json";

            using (var stream =
                       new FileStream(Server.MapPath(credPath1), FileMode.Open, FileAccess.ReadWrite))
            {
                string credPath = Server.MapPath(@"~\Documents\token.json");
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    CalendarScopes.Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, false)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }
            // Create Drive API service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            var _event = new Event();

            _event.Start = new EventDateTime()
            {
                DateTime = DateTime.Parse(model.NewEvent.EventStart.Value.ToLongDateString()),
                TimeZone = "Asia/Kolkata"
            };
            _event.End = new EventDateTime()
            {
                DateTime = DateTime.Parse(model.NewEvent.EventEnd.Value.ToLongDateString()),
                TimeZone = "Asia/Kolkata"
            };
            var _list = new List <EventAttendee>();

            if (model.NewEvent.Attendees[0] == "")
            {
                var att = new EventAttendee()
                {
                    Email = "*****@*****.**"
                };
                _list.Add(att);
            }
            else
            {
                foreach (var item in model.NewEvent.Attendees[0].Split(','))
                {
                    var attendee = new EventAttendee();
                    attendee.Email = item;
                    _list.Add(attendee);
                }
            }
            _event.Attendees = _list;

            _event.Description             = model.NewEvent.Description;
            _event.GuestsCanSeeOtherGuests = true;
            //_event.Location = model.NewEvent.Location;
            _event.Kind      = "calendar#event";
            _event.Summary   = model.NewEvent.EventName;
            _event.ColorId   = "4";
            _event.Reminders = new Event.RemindersData()
            {
                UseDefault = false,
                Overrides  = new EventReminder[] {
                    new EventReminder()
                    {
                        Method = "email", Minutes = 24 * 60
                    }
                }
            };
            //var result = service.Events.Insert(_event, "*****@*****.**");
            EventsResource.InsertRequest request = service.Events.Insert(_event, "*****@*****.**");
            Event createdEvent = request.Execute();

            db.EventCalendar.Add(model.NewEvent);
            db.SaveChanges();
            return(View("UpcomingEvents"));
        }