public async Task <IActionResult> Index()
        {
            try
            {
                var userTimeZone = TZConvert.GetTimeZoneInfo(
                    User.GetUserGraphTimeZone());
                var startOfWeekUtc = CalendarController.GetUtcStartOfWeekInTimeZone(
                    DateTime.Today, userTimeZone);

                var events = await GetUserWeekCalendar(startOfWeekUtc);

                // Convert UTC start of week to user's time zone for
                // proper display
                var startOfWeekInTz = TimeZoneInfo.ConvertTimeFromUtc(startOfWeekUtc, userTimeZone);
                var model           = new CalendarViewModel(startOfWeekInTz, events);

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

                return(View(new CalendarViewModel())
                       .WithError("Error getting calendar view", ex.Message));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Index()
        {
            try
            {
                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 MicrosoftIdentityWebChallengeUserException)
                {
                    throw ex;
                }

                return(View(new CalendarViewModel())
                       .WithError("Error getting calendar view", ex.Message));
            }
        }
Beispiel #3
0
        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));
            }
        }