public async Task <IActionResult> MyTeamRevisionRequest(string date, string searchtext, int draw, int start, int length = 10) { int pageIndex = 0; if (start != 0) { pageIndex = start / length + 1; } if (pageIndex == 0) { pageIndex = 1; } //var dateRequested = DateTime.ParseExact(date, "yyyMMdd", CultureInfo.InvariantCulture); MyTeamDataTableData dataTableData = new MyTeamDataTableData(); if (User.Identity.IsAuthenticated) { MyTeamHoursViewModel myTeamsHoursViewModel = new MyTeamHoursViewModel(); if (_userProfile == null) { _userProfile = await _userProfileRepository.GetItemAsync(); } ViewData["Email"] = _userProfile.Fields.Upn; ViewData["IsManager"] = _userProfile.Fields.IsManager; ViewData["IsHr"] = _userProfile.Fields.IsHr; ViewData["IsAdmin"] = _userProfile.Fields.IsAdmin; ViewData["UserImage"] = _userProfile.Fields.UserPicture; DateTime selDt = DateTime.Now.AddMonths(-1); if (date != null) { selDt = DateTime.Parse(date); } string searchQuery = HttpContext.Request.Query["search[value]"].ToString(); TeamHoursViewModel teamHoursViewModel = new TeamHoursViewModel(); if (searchtext != null) { teamHoursViewModel = await _teamHoursService.GetSearchResults(selDt, searchtext, pageIndex, length); dataTableData = teamHoursViewModel.MyTeamDataTableData; } else { teamHoursViewModel = await _teamHoursService.GetViewModel(selDt, pageIndex, length); dataTableData = teamHoursViewModel.MyTeamDataTableData; } dataTableData.draw = draw; dataTableData.recordsTotal = (pageIndex * length) + dataTableData.data.Count + 1; int recordsFiltered = (pageIndex * length) + dataTableData.data.Count + 1; dataTableData.recordsFiltered = recordsFiltered; if (date == null) { myTeamsHoursViewModel.SearchDate = myTeamsHoursViewModel.fnGetLastMonthEndDate(); } else { myTeamsHoursViewModel.SearchDate = selDt; } myTeamsHoursViewModel.UserInfo = _userProfile; //return View(myTeamsHoursViewModel); if (teamHoursViewModel.MyTeamDataTableData.data.Exists(x => x.SubmittedDate == DateTime.MinValue)) { myTeamsHoursViewModel.IsSubmitted = false; } else { myTeamsHoursViewModel.IsSubmitted = true; } return(Json(dataTableData)); } else { ErrorViewModel EVM = new ErrorViewModel(); return(View(EVM)); } //return Json(dataTableData); }