public ActionResult MenuList() { var queryMenu = menuR.GetAll().OrderBy(p => p.OrderBy);; string dinamicMenu = ""; string url = "http://localhost:25584"; var userRoleId = userR.GetAll().Where(x => x.Login == User.Identity.Name).ToList(); List <int> listRoleuId = new List <int>(); foreach (user u in userRoleId) { listRoleuId.Add(u.RoleId); } List <int> listMenuId = new List <int>(); foreach (int i in listRoleuId) { listMenuId.AddRange(menuRoleR.GetAll().Where(x => x.RoleId == i).Select(x => x.MenuId)); } var listMRR = mRR.GetAll(); foreach (menu c in queryMenu) { if (listMenuId.Contains(c.Id)) { var queryReport = listMRR.Where(p => p.MenuId == c.Id).OrderBy(p => p.OrderBy); if (queryReport.Count() > 0) { dinamicMenu += "<li class='dropdown'>" + "<a href='" + c.Link + "' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>" + c.Name + " <span class='caret'></span></a>"; } else { dinamicMenu += "<li><a href='" + c.Link + "'>" + c.Name + "</a>"; } if (queryReport.Count() > 0) { dinamicMenu += " <ul class='dropdown-menu'>"; foreach (menuReport r in queryReport) { dinamicMenu += "<li><a href='" + url + "/home/index/" + r.Link + "/" + r.TypeReport + "'>" + r.Name + "</a></li>"; } dinamicMenu += "</ul>"; } dinamicMenu += "</li>"; } } ViewBag.menu = dinamicMenu; return(PartialView()); }
public bool validLogin(string user, string pass) { try { userRepository userlogin = new userRepository(); var ul = userlogin.GetAll(); user u = ul.Where(x => x.Login == user).First(); if (Criptografic.Compara(pass, u.Password)) { return(true); } else { return(false); } } catch { return(false); } }
// // GET: /User/ public ActionResult Index() { var lk = ur.GetAll(); return(View(lk)); }