コード例 #1
0
        // Take data and put into Index view.
        public ActionResult Index(CreateEventResponse createEventResponse, EventInfo eventInfo)
        {
            ValidateInfo(ref eventInfo);

            ViewBag.EventInfo = eventInfo;
            ViewBag.CreateEventResponse = createEventResponse;

            return View();
        }
コード例 #2
0
        // Use the login user name or recipient email address if no user name.
        void ValidateInfo(ref EventInfo eventInfo)
        {
            var currentUser = (UserInfo)Session[SessionKeys.Login.UserInfo];

            if (eventInfo == null || string.IsNullOrEmpty(eventInfo.StartTime.ToString()) || string.IsNullOrEmpty(eventInfo.EndTime.ToString()) || string.IsNullOrEmpty(eventInfo.Subject))
            {
                eventInfo.StartTime = DateTime.Now;
                eventInfo.EndTime = DateTime.Now.AddHours(1);
                eventInfo.TimeZone = "Central Standard Time";
                eventInfo.Subject = Settings.EventSubject;
                eventInfo.Body = Settings.EventBody;
            }
        }
コード例 #3
0
        public async Task<ActionResult> CreateEventSubmit(EventInfo eventInfo)
        {
            // After Index method renders the View, user clicks Send Mail, which comes in here.
            ValidateInfo(ref eventInfo);

            // Create Event using the Microsoft Graph API.
            var createEventResult = await UnifiedApiHelper.CreateEventAsync(
                (string)Session[SessionKeys.Login.AccessToken],
                GenerateEvent(eventInfo.StartTime, eventInfo.EndTime, eventInfo.TimeZone, eventInfo.Subject, eventInfo.Body));

            // Reuse the Index view for events (created, not created, failed) .
            // Redirect to tell the browser to call the app back via the Index method.
            return RedirectToAction(nameof(Index), new RouteValueDictionary(new Dictionary<string, object>{
                { "Status", createEventResult.Status },
                { "StatusMessage", createEventResult.StatusMessage },
                { "StartTime", eventInfo.StartTime },
                { "EndTime", eventInfo.EndTime },
                { "Subject", eventInfo.Subject },
                { "TimeZone", eventInfo.TimeZone },
                { "Body", eventInfo.Body },
            }));
        }