Ejemplo n.º 1
0
        public async Task <InvokeResult> UpdateSimulatorAsync(Models.Simulator simulator, EntityHeader org, EntityHeader user)
        {
            await AuthorizeAsync(simulator, AuthorizeActions.Create, user, org);

            await _simulatorRepo.UpdateSimulatorAsync(simulator);

            return(InvokeResult.Success);
        }
Ejemplo n.º 2
0
        public async Task <InvokeResult> UpdateSimulatorAsync(Models.Simulator simulator, EntityHeader org, EntityHeader user)
        {
            await AuthorizeAsync(simulator, AuthorizeActions.Create, user, org);

            if (!String.IsNullOrEmpty(simulator.Password))
            {
                if (!String.IsNullOrEmpty(simulator.PasswordSecureId))
                {
                    await _secureStorage.RemoveSecretAsync(org, simulator.PasswordSecureId);
                }

                var result = await _secureStorage.AddSecretAsync(org, simulator.Password);

                if (!result.Successful)
                {
                    return(result.ToInvokeResult());
                }

                simulator.PasswordSecureId = result.Result;
                simulator.Password         = null;
            }

            if (!String.IsNullOrEmpty(simulator.AccessKey))
            {
                if (!String.IsNullOrEmpty(simulator.AccessKeySecureId))
                {
                    await _secureStorage.RemoveSecretAsync(org, simulator.AccessKeySecureId);
                }

                var result = await _secureStorage.AddSecretAsync(org, simulator.AccessKey);

                if (!result.Successful)
                {
                    return(result.ToInvokeResult());
                }

                simulator.AccessKeySecureId = result.Result;
                simulator.AccessKey         = null;
            }

            if (!String.IsNullOrEmpty(simulator.AuthHeader))
            {
                if (!String.IsNullOrEmpty(simulator.AuthHeaderSecureId))
                {
                    await _secureStorage.RemoveSecretAsync(org, simulator.AuthHeaderSecureId);
                }

                var result = await _secureStorage.AddSecretAsync(org, simulator.AuthHeader);

                if (!result.Successful)
                {
                    return(result.ToInvokeResult());
                }

                simulator.AuthHeaderSecureId = result.Result;
                simulator.AuthHeader         = null;
            }

            await _simulatorRepo.UpdateSimulatorAsync(simulator);

            return(InvokeResult.Success);
        }