예제 #1
0
 public async Task <ActionResult> Details(string id)
 {
     ExchangeClientDemo.Models.MyEvent myEvent = null;
     try {
         MyEventsRepository repo = new MyEventsRepository();
         myEvent = await repo.GetEvent(id);
     }
     catch (RedirectRequiredException x) {
         return(Redirect(x.RedirectUri.ToString()));
     }
     return(View(myEvent));
 }
예제 #2
0
        public async Task <ActionResult> Create(ExchangeClientDemo.Models.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));
            }
        }
        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.Location = myEvent.Location.DisplayName;
                }

                eventList.Add(newEvent);
            }

            return(eventList);
        }