public async Task <ActionResult <IEnumerable <ApplicationDeploymentDto> > > GetDeployments([FromQuery(Name = "application")] string applicationName, [FromQuery(Name = "status")] DeploymentStatus?status)
        {
            try
            {
                Application application = null;
                if (!string.IsNullOrEmpty(applicationName))
                {
                    application = _applicationService.GetApplication(applicationName);
                }

                var deployments = await _deploymentService.GetDeployments(application, status);

                var result = deployments.Select(ConvertFromModel).ToList();

                return(Ok(result.AsEnumerable()));
            }
            catch (Exception e)
            {
                return(NotFound());
            }
        }
Exemple #2
0
        private async Task <IReadOnlyCollection <ListDeploymentViewModel> > GetDeploymentList(Server server)
        {
            IReadOnlyCollection <Deployment> deployments = await _deploymentService.GetDeployments(server.Name);

            List <ListDeploymentViewModel> viewModels = new List <ListDeploymentViewModel>();

            foreach (Deployment deployment in deployments)
            {
                viewModels.Add(new ListDeploymentViewModel
                {
                    BuildPath  = deployment.BuildPath,
                    Id         = deployment.Id,
                    LastBackup = !string.IsNullOrEmpty(server.Paths.Backup) ? await _remoteService.GetLastBackup(deployment.Id) : null,
                    LastUpload = !string.IsNullOrEmpty(server.Paths.Deploy) ? await _remoteService.GetLastUpload(deployment.Id) : null,
                    Name       = deployment.Name,
                    Offline    = !string.IsNullOrEmpty(deployment.OfflineFile) ? await _remoteService.IsOffline(deployment.Id) : default(bool?),
                    RemotePath = deployment.RemotePath
                });
            }

            return(viewModels);
        }