Access a class attribute in an ASP NET Controller

Asked

Viewed 77 times

0

I would like in my system Crud ASP.NET to make an image in the form of a padlock disabled when a certain user profile log in to the system, the name of this controller below is called Maintainability inserir a descrição da imagem aqui

My idea is to take advantage of and save in Session the information that is in the Controller Loggincontroller.Cs and call in Maintenancepower, but I assembled the first part of the access to the attribute of the class that comes empty and wanted to know how to bringla, below is the code of the Maintainability:

public Jsonresult _Listirfinalities() { List purposes = new list();

        using (var ws = new VREWebServiceClient())
        {
            ObterFinalidadeResponse obj = new ObterFinalidadeResponse();
            /* Eu */ 
            BSeguranca BSeguranca = new BSeguranca();

            Usuario usuario = new Usuario();
            int Recebe_NMUsuario = usuario.NUsuario;


            obj = ws.ObterFinalidade(false);
            bool historico;
            string acaoHistorico = string.Empty;

            var objHistorico = obj.Finalidade.Where(w => w.DatVigncAte != null);

            foreach (var item in obj.Finalidade)
            {
                historico = false;

                string acaoVisualizarFinalidade = String.Format("<a href=\"/ManterFinalidade/VisualizarFinalidade?codigo={0}\" title=\"Dados da Finalidade\"><img src=\"/Content/images/detalhes.png\" style=\"cursor: pointer;\" width=\"16px\" border=\"0\"></a>", item.CodFinld);
                string acaoAssociarDeclaracaoFinalidade = String.Format("<a href=\"/ManterFinalidade/AssociarDeclaracaoFinalidade?codigo={0}\" title=\"Associar Declaração - Finalidade\"><img src=\"/Content/images/associar.png\" style=\"cursor: pointer;\" width=\"16px\" border=\"0\"></a>", item.NumFinld);

                foreach (var x in objHistorico)
                {
                    if (x.CodFinld == item.CodFinld)
                        historico = true;
                }

                if (historico)
                    acaoHistorico = "<img src=\"/Content/images/historico.png\" style=\"cursor: pointer;\" title=\"Visualizar Histórico\" width=\"16px\" border=\"0\" class=\"accordion\">";
                else
                    acaoHistorico = "<img src=\"/Content/images/historico_off.png\" title=\"Visualizar Histórico\" width=\"16px\" border=\"0\">";

                if (item.DatVigncAte == null)
                {
                    finalidades.Add(new EFinalidadeGrid()
                    {
                        CodFinld = item.CodFinld,
                        DesFinld = item.DesFinld,
                        DatVigncDe = item.DatVigncDe,
                        DatVigncAte = item.DatVigncAte,
                        HtmlAcoes = String.Format("{0}&nbsp;&nbsp;&nbsp;{1}&nbsp;&nbsp;&nbsp;{2}", acaoHistorico, acaoVisualizarFinalidade, acaoAssociarDeclaracaoFinalidade)
                    });
                }
            }
        }

        return Json(new
        {
            Retorno = finalidades
        }, JsonRequestBehavior.AllowGet);
    }

In the next image, I want to capture the value of the Nusuario attribute that is equal to 16783 for technical profile and compare with line 60 if it is technical profile, shows the disabled image, otherwise it enables if it is another profile:

inserir a descrição da imagem aqui

Can anyone help me, what is missing to bring the data filled in image 2?

Personal thank you

1 answer

0

Good people,

O esquema era esse mesmo:

user = new user(); user.attribute = value; But at the moment that is not what I will use, there will be a feature that I will use to compare with Enum.

Personal thank you.

Browser other questions tagged

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