Ejemplo n.º 1
0
        public IActionResult AddSecret(int clientId, EditableSecretViewModel secret)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = ViewModelBuilder.BuildClientAddSecretViewModel(ModelState, clientId, secret);

                return(View(viewModel));
            }

            var secretModel = Mapper.Map <SecretModel>(secret);

            var result = m_secretManager.AddSecretToClient(clientId, secretModel);

            if (result.HasError)
            {
                ModelState.AddModelError(result.Error.Message);

                var viewModel = ViewModelBuilder.BuildClientAddSecretViewModel(ModelState, clientId, secret);

                return(View(viewModel));
            }

            return(RedirectToAction(nameof(Secrets), new { clientId }));
        }