コード例 #1
0
        // GET: Menus/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Menus menus = db.Menus.Find(id);

            IndexMenuViewModel model = new IndexMenuViewModel()
            {
                Id             = menus.Id,
                ParentId       = menus.ParentId,
                ParentName     = menus.ParentId == 0 ? defFather : db.Menus.Find(menus.ParentId).Name,
                Name           = menus.Name,
                ActionName     = menus.ActionName,
                ControllerName = menus.ControllerName,
                RoleName       = menus.RoleName,
                Title          = menus.Title,
                Status         = menus.Status,
                StatusName     = menus.Status == "A" ? "Activo" : "INACTIVO"
            };

            if (menus == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
コード例 #2
0
        // GET: Menus
        public ActionResult Index()
        {
            List <IndexMenuViewModel> model = new List <IndexMenuViewModel>();

            foreach (var item in db.Menus.ToList())
            {
                IndexMenuViewModel imvm = new IndexMenuViewModel()
                {
                    Id             = item.Id,
                    ParentId       = item.ParentId,
                    ParentName     = item.ParentId == 0 ? defFather : db.Menus.Find(item.ParentId) == null ? defFather : db.Menus.Find(item.ParentId).Name,
                    Name           = item.Name,
                    ActionName     = item.ActionName,
                    ControllerName = item.ControllerName,
                    RoleName       = item.RoleName,
                    Title          = item.Title,
                    Status         = item.Status,
                    StatusName     = item.Status == "A" ? "ACTIVO" : "INACTIVO"
                };

                model.Add(imvm);
            }

            return(View(model.ToList()));
        }