I'm coming from PHP
and learning C#
MVC
while migrating the applications I have.
I came across the following problem that I can not find a solution:
This is my class that generates the menu dynamically in the system:
public class WebEstMenuAplicacao
{
private ConexaoOracle bd;
public List<WebEstMenu> MenuSistema(int gru_in_codigo)
{
using (bd = new ConexaoOracle())
{
var strQuery = "select " +
" t.men_in_codigo, " +
" t.men_st_descricao," +
" t.men_st_caminho," +
" t.men_st_icone," +
" t.men_st_status" +
" from " +
" MGESTOQUE.WEB_EST_SYSMENU t ";
//strQuery += string.Format(" t.gru_in_codigo= ('{0}')", gru_in_codigo);
var retorno = bd.ExecutaComandoComRetorno(strQuery);
return ReaderEmListaMenu(retorno);
}
}
public List<WebEstMenu> ReaderEmListaMenu(OracleDataReader reader)
{
var tabAplicacao = new List<WebEstMenu>();
while (reader.Read())
{
var tempoObjeto = new WebEstMenu()
{
men_in_codigo = int.Parse(reader["men_in_codigo"].ToString()),
men_st_descricao = reader["men_st_descricao"].ToString(),
men_st_caminho = reader["men_st_caminho"].ToString(),
men_st_icone = reader["men_st_icone"].ToString(),
men_st_status = int.Parse(reader["men_st_status"].ToString())
};
tabAplicacao.Add(tempoObjeto);
}
reader.Close();
return tabAplicacao;
}
}
This is my controller:
public ActionResult Index()
{
if (tempData.vORG_IN_CODIGO > 0)
{
var appWebEstMenu = new WebEstMenuAplicacao();
var webEstMenu = appWebEstMenu.MenuSistema(tempData.vGRU_IN_CODIGO);
if (webEstMenu == null)
{
return HttpNotFound();
}
return View(webEstMenu);
}
else
{
TempData["msg"] = "<script>jAlert('Sua sessão expirou favor logar novamente.','Erro');</script>";
return RedirectToAction("Index", "Login");
}
}
This code generates the menu on my system by checking the employee's access level. Until that moment I have achieved it normally, but I am not able to implement the submenu check. Where it should go through the MENU LIST and search the submenu items. And then return the two models for my view.
SubMenu Table
select t.sub_in_codigo,
t.men_in_codigo,
t.sub_st_descricao,
t.sub_st_icone,
t.sub_in_status,
t.sub_st_url
from
MGESTOQUE.WEB_EST_SYSSUBMENU t