syntax pass value via post Razor Asp.net mvc

Asked

Viewed 45 times

0

I’m trying to make a method to change via POST in my code and is giving syntax error, I do as follows:

@Ajax.ActionLink(" ", "Usuario", new
                                {
                                    item.CodigoUsuario
                                }, new AjaxOptions { UpdateTargetId = "div-usuario-index", HttpMethod = "POST" }, new { @class = "editar btn btn-sm btn-primary glyphicon glyphicon-edit", @name = "command:alterar" })

Controller:

[HttpPost]
        [ClearModelState]
        [CommandName("Alterar", "command:alterar")]
        public async Task<ActionResult> AlterarAsync(UsuarioViewModel model)
        {


            model = await this.BuscarUsuarioAsync(model.CodigoUsuario);
            try
            {
                var pessoaFisica = await this.PessoaApplicationService.BuscarPessoaCompletaPorCNPJCPFAsync(model.NumeroCpf);
                pessoaFisica = pessoaFisica ?? new PessoaFisica();

                model.NomeCompleto = pessoaFisica.NomeCompleto;
                model.NumeroCpf = pessoaFisica.NumeroCpf;
                model.NumeroTelefone = pessoaFisica.NumeroTelefone;
                model.DescricaoEndereco = pessoaFisica.DescricaoEndereco;
                model.NomeMunicipio = pessoaFisica.NomeMunicipio;

                model.DescricaoSenha = string.Empty;
                model.RepetirSenha = string.Empty;

                model.RepetirSenha = model.DescricaoSenha;
                ModelState.Remove("DescricaoSenha");
                ModelState.Remove("RepetirSenha");
                Session["Id"] = pessoaFisica.Id;
                return View("Alterar", model);
            }
            catch (BusinessException ex)
            {

                Session["Id"] = model.CodigoUsuario;
                HandleBusinessException(ex);
                return View("Alterar", model);
            }
        }

Does anyone know how I can do that ?

  • There is little information, at which moment the error occurs?

  • at compile time it already says that the syntax is incorrect

  • But what line is that there ?

  • I changed the way I step in Razor and controller, I edited the post with the changes, now I click change and nothing happens....

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.