public async Task <IActionResult> Index()
        {
            //var gmailAuthService = scope.ServiceProvider.GetRequiredService<IGoogleAuthService>();

            //var credentials = await gmailService.AcquireCredentialsAsync();

            //if (credentials == null)
            //{
            //    //return;
            //}
            //else
            //{
            //var accessToken = await gmailService.GetAccessToken(credentials);

            //var gmailApiService = scope.ServiceProvider.GetRequiredService<IGmailApiService>();

            //await apiService.SaveEmailsToDbAsync(accessToken);

            //this.logger.LogInformation("Scoped service id: " + service.Id);
            //}

            var credentials = await gmailService.CheckForTokensAsync();

            var accessToken = await gmailService.GetAccessToken(credentials);

            // this.emailService.SetInitialStatusAsync();
            // var emails = await this.apiService.SyncEmails(accessToken);
            //var latest = this.emailService.GetAllEmails(5);

            var homeViewModel = new HomeViewModel
            {
                LatestEmails = this.emailService
                               .GetAllEmails(5)
                               .Select(e => emailMapper.PartialMapFrom(e))
                               .ToList(),

                LastModified = this.emailService
                               .GetLastModifiedEmails(5)
                               .Select(e => emailMapper.PartialMapFrom(e))
                               .ToList(),

                ApprovedAndNew = this.emailService
                                 .GetApprovedAndNewEmails(5)
                                 .Select(e => emailMapper.PartialMapFrom(e))
                                 .ToList(),
            };

            return(View(homeViewModel));
        }
        public async Task <IActionResult> StartProgram()
        {
            var credentials = await gmailAuthService.CheckForTokensAsync();

            if (credentials == null)
            {
                return(RedirectToAction("GoogleLogin", "Gmail"));
            }
            else
            {
                var accessToken = await gmailAuthService.GetAccessToken(credentials);

                await gmailService.SyncEmails(accessToken);

                return(RedirectToAction("Index", "Home"));
            }
        }