コード例 #1
0
    public async Task<List<MyEvent>> GetEvents() {

      var client = await EnsureClientCreated();

      var eventsResults = await (from ev in client.Me.Events
                                 where ev.End >= DateTimeOffset.UtcNow
                                 select ev).Take(10).ExecuteAsync();

      var events = eventsResults.CurrentPage.OrderBy(e => e.Start);

      var eventList = new List<MyEvent>();

      foreach (var myEvent in events) {
        MyEvent newEvent = new MyEvent();
        newEvent.Id = myEvent.Id;
        newEvent.Subject = myEvent.Subject;
        newEvent.Start = myEvent.Start;
        myEvent.End = myEvent.End;
        if (myEvent.Body != null) {
          newEvent.Body = myEvent.Body.Content;
        }
        if (myEvent.Location != null) {
          newEvent.Location = myEvent.Location.DisplayName;
        }
        if (myEvent.Start != null) {
          newEvent.Start = myEvent.Start;
        }

        eventList.Add(newEvent);
      }

      return eventList;

    }
コード例 #2
0
    public async Task<ActionResult> Create(MyEvent myEvent) {

      if (Request.HttpMethod == "POST") {
        MyEventsRepository repo = new MyEventsRepository();
        await repo.AddEvent(myEvent);
        return Redirect("/Events");
      } else {
        myEvent.Start = DateTimeOffset.Now;
        myEvent.End = DateTimeOffset.Now.AddDays(1);
        return View(myEvent);
      }
    }
コード例 #3
0
    public async Task AddEvent(MyEvent myEvent) {
      var client = await EnsureClientCreated();

      Location myEventLocation = new Location();
      myEventLocation.DisplayName = myEvent.Location;

      var newEvent = new Event {
        Subject = myEvent.Subject,
        Start = myEvent.Start,
        End = myEvent.End,
        Location = myEventLocation
      };
      await client.Me.Events.AddEventAsync(newEvent);
    }
コード例 #4
0
    public async Task<MyEvent> GetEvent(string id) {
      var client = await EnsureClientCreated();
      var ev = await client.Me.Events.GetById(id).ExecuteAsync();

      MyEvent newEvent = new MyEvent();
      newEvent.Id = ev.Id;
      newEvent.Subject = ev.Subject;
      newEvent.Start = ev.Start;
      newEvent.End = ev.End;
      if (ev.Location != null) {
        newEvent.Location = ev.Location.DisplayName;
      }
      if (ev.Body != null) {
        newEvent.Body = ev.Body.Content;
      }

      return newEvent;
    }
コード例 #5
0
        public async Task <MyEvent> GetEvent(string id)
        {
            var client = await EnsureClientCreated();

            var ev = await client.Me.Events.GetById(id).ExecuteAsync();

            MyEvent newEvent = new MyEvent();

            newEvent.Id      = ev.Id;
            newEvent.Subject = ev.Subject;
            newEvent.Start   = ev.Start;
            newEvent.End     = ev.End;
            if (ev.Location != null)
            {
                newEvent.Location = ev.Location.DisplayName;
            }
            if (ev.Body != null)
            {
                newEvent.Body = ev.Body.Content;
            }

            return(newEvent);
        }
コード例 #6
0
        public async Task <List <MyEvent> > GetEvents()
        {
            var client = await EnsureClientCreated();

            var eventsResults = await(from ev in client.Me.Events
                                      where ev.End >= DateTimeOffset.UtcNow
                                      select ev).Take(10).ExecuteAsync();

            var events = eventsResults.CurrentPage.OrderBy(e => e.Start);

            var eventList = new List <MyEvent>();

            foreach (var myEvent in events)
            {
                MyEvent newEvent = new MyEvent();
                newEvent.Id      = myEvent.Id;
                newEvent.Subject = myEvent.Subject;
                newEvent.Start   = myEvent.Start;
                myEvent.End      = myEvent.End;
                if (myEvent.Body != null)
                {
                    newEvent.Body = myEvent.Body.Content;
                }
                if (myEvent.Location != null)
                {
                    newEvent.Location = myEvent.Location.DisplayName;
                }
                if (myEvent.Start != null)
                {
                    newEvent.Start = myEvent.Start;
                }

                eventList.Add(newEvent);
            }

            return(eventList);
        }