public ActionResult Edit(int id) { Context.Role dbitem = RepoRole.FindByPK(id); Role model = new Role(dbitem); ViewBag.name = model.name; return(View("Form", model)); }
public string Binding(string modul, int role_id) { Context.Role role = RepoRole.FindByPK(role_id); List <Context.Menu> items = RepoMenu.FindAll().Where(d => d.Modul == modul && !role.RoleMenus.Select(f => f.IdMenu).Contains(d.Id)).ToList(); List <RoleMenu> ListModel = new List <RoleMenu>(); foreach (Context.Menu item in items) { ListModel.Add(new RoleMenu(item)); } foreach (Context.RoleMenus item in role.RoleMenus.Where(d => RepoMenu.FindAll().Where(f => f.Modul == modul).Select(e => e.Id).ToList().Contains(d.IdMenu.Value))) { ListModel.Add(new RoleMenu(item)); } return(new JavaScriptSerializer().Serialize(new { total = ListModel.Count(), data = ListModel })); }