// GET /Calendar
        // Displays a calendar view of the current week for
        // the logged-in user
        public async Task <IActionResult> Index()
        {
            await EnsureScopes(_calendarScopes);

            try
            {
                // TZConvert handles either an IANA or Windows identifier
                // Graph can return either
                var userTimeZone = TZConvert.GetTimeZoneInfo(
                    User.GetUserGraphTimeZone());
                var startOfWeek = CalendarController.GetUtcStartOfWeekInTimeZone(
                    DateTime.Today, userTimeZone);

                var events = await GetUserWeekCalendar(startOfWeek);

                var model = new CalendarViewModel(startOfWeek, events);

                return(View(model));
            }
            catch (ServiceException ex)
            {
                InvokeAuthIfNeeded(ex);

                return(View(new CalendarViewModel())
                       .WithError("Error getting calendar view", ex.Message));
            }
        }
        // GET /Calendar
        // Displays a calendar view of the current week for
        // the logged-in user
        public async Task <IActionResult> Index()
        {
            try
            {
                // TZConvert handles either an IANA or Windows identifier
                // Graph can return either
                var userTimeZone = TZConvert.GetTimeZoneInfo(
                    User.GetUserGraphTimeZone());
                var startOfWeek = CalendarController.GetUtcStartOfWeekInTimeZone(
                    DateTime.Today, userTimeZone);

                var events = await GetUserWeekCalendar(startOfWeek);

                var model = new CalendarViewModel(startOfWeek, events);

                return(View(model));
            }
            catch (ServiceException ex)
            {
                if (ex.InnerException is MsalUiRequiredException)
                {
                    throw;
                }

                return(View(new CalendarViewModel())
                       .WithError("Error getting calendar view", ex.Message));
            }
        }
Beispiel #3
0
        // GET /Calendar
        // Displays a calendar view of the current week for
        // the logged-in user
        public async Task <IActionResult> Index()
        {
            try
            {
                var userTimeZone = TimeZoneInfo.FindSystemTimeZoneById(
                    User.GetUserGraphTimeZone());
                var startOfWeek = CalendarController.GetUtcStartOfWeekInTimeZone(
                    DateTime.Today, userTimeZone);

                var events = await GetUserWeekCalendar(startOfWeek);

                var model = new CalendarViewModel(startOfWeek, events);

                return(View(model));
            }
            catch (ServiceException ex)
            {
                if (ex.InnerException is MsalUiRequiredException)
                {
                    throw ex;
                }

                return(View(new CalendarViewModel())
                       .WithError("Error getting calendar view", ex.Message));
            }
        }