public async Task <IActionResult> Index() { if (User.Identity.IsAuthenticated) { // Get UserProfile details if (_userProfile == null) { _userProfile = await _userProfileRepository.GetItemAsync(); } ViewData["Email"] = _userProfile.Fields.Mail; ViewData["IsManager"] = _userProfile.Fields.IsManager; ViewData["IsHr"] = _userProfile.Fields.IsHr; ViewData["IsAdmin"] = _userProfile.Fields.IsAdmin; ViewData["UserImage"] = _userProfile.Fields.UserPicture; String firstDayOfWeek = _userProfile.Fields.FirstDayWeek; // Get current week data for Dashboard initially string dataBoundary = "CurrentWeek"; var spSiteList = new SiteList { SiteId = _timeTrackerOptions.SharePointSiteId, ListId = _timeTrackerOptions.WorkHoursListPrefix + _userProfile.Id }; var isExisted = await _graphSharePointService.TryGetSiteListAsync(spSiteList); if (isExisted) { dataBoundary = "All"; ViewBag.dataBoundary = "All"; } var dashboardViewModel = await _dataServiceClient.GetWorkHours(DateTime.Now, "current", firstDayOfWeek, dataBoundary); dashboardViewModel.currentWeekData = (isExisted == true) ? false : true; dashboardViewModel.UserInfo = _userProfile; dashboardViewModel.WorkHoursEditable = (isExisted == true) ? true : false; return(View(dashboardViewModel)); } else { ErrorViewModel EVM = new ErrorViewModel(); return(View(EVM)); } }