예제 #1
0
        public async Task <InvokeResult <DeploymentInstance> > LoadFullInstanceAsync(string id, EntityHeader org, EntityHeader user)
        {
            var instance = await _instanceRepo.GetInstanceAsync(id);

            await AuthorizeAsync(instance, AuthorizeResult.AuthorizeActions.Read, user, org);

            instance.DeviceRepository.Value = await _deviceRepoManager.GetDeviceRepositoryAsync(instance.DeviceRepository.Id, org, user);

            var solutionResult = await _solutionManager.LoadFullSolutionAsync(instance.Solution.Id, org, user);

            if (solutionResult.Successful)
            {
                instance.Solution.Value = solutionResult.Result;
                instance.Solution.Id    = instance.Solution.Value.Id;
                instance.Solution.Text  = instance.Solution.Value.Name;
                return(InvokeResult <DeploymentInstance> .Create(instance));
            }
            else
            {
                return(InvokeResult <DeploymentInstance> .FromErrors(solutionResult.Errors.ToArray()));
            }
        }