Ejemplo n.º 1
0
        public async Task <IActionResult> IndexAsync()
        {
            try
            {
                if (!_credentialsRepository.IsUserSetted())
                {
                    return(RedirectToAction("Login"));
                }

                var repositories = await _repositoryPersistence.GetAllAsync();

                if (repositories == null || !repositories.Any())
                {
                    return(View(null));
                }

                var pullRequests = await _pullRequestRepository.GetAllAsync(repositories);

                return(View(pullRequests.ConvertToViewModel().OrderByDescending(x => x.TotalOpenTimeInMinutes).ToArray()));
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "An error occurred retrieving the Pull Requests.");
            }
            return(View());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> IndexAsync()
        {
            try
            {
                // TODO make this middleware for relevant actions.
                if (!_credentialsRepository.IsUserSetted())
                {
                    return(RedirectToAction("Index", "Home"));
                }

                var organisationModels = new List <OrganisationModel>();

                // TODO rename the class to some that cover this use case.
                organisationModels.Add(new OrganisationModel
                {
                    Name         = _credentialsRepository.User.Username,
                    Repositories = (await _repositoryRepository.GetAllForCurrentAsync()).ConvertToModel()
                });

                var organisations = await _organisationRepository.GetOrganisationsAsync();

                foreach (var organisation in organisations)
                {
                    var organisationModel = new OrganisationModel
                    {
                        Name         = organisation.Name,
                        Repositories = (await _repositoryRepository.GetAllAsync(organisation)).ConvertToModel()
                    };
                    organisationModels.Add(organisationModel);
                }

                return(View(new OrganisationRepositoriesViewModel(organisationModels,
                                                                  await _repositoryPersistence.GetAllAsync())));
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, exception.Message);
                throw;
            }
        }