public ActionResult Update(int id) { var model = new MenuDao().GetByID(id); GetDropdown(int.Parse(model.ParentID.ToString())); return(View(model)); }
public ActionResult Create(Model.EF.Menu entity) { if (ModelState.IsValid) { int id; try { if (entity.ParentID == null) { entity.ParentID = 0; } entity.Status = true; id = new MenuDao().Insert(entity); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Menu", "Index"))); } if (id > 0) { ModelState.AddModelError("", "Thêm mới thành công"); return(RedirectToAction("Index", "Menu")); } else { ModelState.AddModelError("", "Thêm mới không thành công"); return(View()); } } else { ModelState.AddModelError("", "Vui lòng nhập đầy đủ thông tin"); return(View()); } }
public ActionResult Update(Model.EF.Menu entity) { bool result; if (ModelState.IsValid) { try { result = new MenuDao().Update(entity); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Menu", "Update"))); } if (result) { ModelState.AddModelError("", "Cập nhật thành công"); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); return(View()); } } else { ModelState.AddModelError("", "Vui lòng nhập đầy đủ"); return(View()); } }
public static IList <MenuInfo> GetMenus(string shopMenuStyle) { IList <MenuInfo> list = new List <MenuInfo>(); MenuDao menuDao = new MenuDao(); IList <MenuInfo> topMenus = menuDao.GetTopMenus(); IList <MenuInfo> result; if (topMenus == null) { result = list; } else { foreach (MenuInfo current in topMenus) { IList <MenuInfo> menusByParentId = menuDao.GetMenusByParentId(current.MenuId); if (shopMenuStyle != "1") { current.ShopMenuPic = ""; } current.SubMenus = menusByParentId; list.Add(current); } result = list; } return(result); }
public static IList <MenuInfo> GetMenus(string shopMenuStyle) { IList <MenuInfo> menuInfos; IList <MenuInfo> menuInfos1 = new List <MenuInfo>(); MenuDao menuDao = new MenuDao(); IList <MenuInfo> topMenus = menuDao.GetTopMenus(); if (topMenus != null) { foreach (MenuInfo topMenu in topMenus) { IList <MenuInfo> menusByParentId = menuDao.GetMenusByParentId(topMenu.MenuId); if (shopMenuStyle != "1") { topMenu.ShopMenuPic = ""; } topMenu.SubMenus = menusByParentId; menuInfos1.Add(topMenu); } menuInfos = menuInfos1; } else { menuInfos = menuInfos1; } return(menuInfos); }
public ActionResult TopMenu() { var menuDao = new MenuDao(); var list = menuDao.GetByGroupId(2); return(PartialView(list)); }
public ActionResult TopMenu() { var dao = new MenuDao(); var model = dao.ListByGroupId(2); return(PartialView(model)); }
// GET: Admin/Menu public ActionResult Index() { var db = new MenuDao(); var model = db.ListByGroupId(2); return(View(model)); }
// GET: Admin/Menu/Edit/5 public ActionResult Edit(int id) { var db = new MenuDao(); var model = db.GetByID(id); return(View(model)); }
public ActionResult MainMenu() { // MenuType = 1 var model = new MenuDao().ListByGroupId(1); return(PartialView(model)); }
public ActionResult TopMenu() { // MenuType = 2 var model = new MenuDao().ListByGroupId(2); return(PartialView(model)); }
public ActionResult Header() { var model = new MenuDao().ListAll(1); ViewBag.ProductCategory = new ProductCategoryDao().ListAllProductCatregory(); return(PartialView(model)); }
// GET: Admin/Menu public ActionResult Index(int page = 1, int pageSize = 10) { var dao = new MenuDao(); var model = dao.ListAllPaging(page, pageSize); return(View(model)); }
public ActionResult MenuTop() { var menuDao = new MenuDao(); var list = menuDao.ListByTypeID(2); return(PartialView(list)); }
private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var menuInfo = (MenuInfo)e.Item.DataItem; var ltlTitle = (Literal)e.Item.FindControl("ltlTitle"); var phMenus = (PlaceHolder)e.Item.FindControl("phMenus"); var rptMenus = (Repeater)e.Item.FindControl("rptMenus"); var ltlActions = (Literal)e.Item.FindControl("ltlActions"); ltlTitle.Text = menuInfo.Title; var menuInfoList = MenuDao.GetMenuInfoList(menuInfo.Id); if (menuInfoList.Count > 0) { phMenus.Visible = true; rptMenus.DataSource = menuInfoList; rptMenus.ItemDataBound += RptMenus_ItemDataBound; rptMenus.DataBind(); } ltlActions.Text = $@" <a href=""{PageMenuSettings.GetRedirectUrl(menuInfo.Id, 0)}"" class=""m-r-10"" onclick=""event.stopPropagation();"">新增二级菜单</a> <a href=""{PageMenuSettings.GetRedirectUrl(menuInfo.ParentId, menuInfo.Id)}"" class=""m-r-10"" onclick=""event.stopPropagation();"">编辑</a> <a href=""{GetRedirectUrl()}?up={true}&parentId={menuInfo.ParentId}&menuId={menuInfo.Id}"" class=""m-r-10"">上升</a> <a href=""{GetRedirectUrl()}?down={true}&parentId={menuInfo.ParentId}&menuId={menuInfo.Id}"" class=""m-r-10"">下降</a> <script>function del() {{{Utils.SwalWarning("删除菜单", $"此操作将删除菜单“{menuInfo.Title}”,确认吗?", "取消", "删除", $"location.href = '{GetRedirectUrl()}?delete={true}&menuId={menuInfo.Id}'")}}}</script> <a href=""javascript:;"" onclick=""event.stopPropagation();del();"">删除</a>"; }
public ActionResult Create(Menu menu) { var menudao = new MenuDao(); long id = menudao.Insert(menu); return(View()); }
public static IList <MenuInfo> GetMenus() { IList <MenuInfo> menuInfos; IList <MenuInfo> menuInfos1 = new List <MenuInfo>(); MenuDao menuDao = new MenuDao(); IList <MenuInfo> topMenus = menuDao.GetTopMenus(); if (topMenus != null) { foreach (MenuInfo topMenu in topMenus) { menuInfos1.Add(topMenu); IList <MenuInfo> menusByParentId = menuDao.GetMenusByParentId(topMenu.MenuId); if (menusByParentId != null) { foreach (MenuInfo menuInfo in menusByParentId) { menuInfos1.Add(menuInfo); } } } menuInfos = menuInfos1; } else { menuInfos = menuInfos1; } return(menuInfos); }
public MenuCRUDService(IUnitOfWork unitOfWork) : base(unitOfWork) { _menuDao = new MenuDao(unitOfWork); _orderDao = new OrderDao(unitOfWork); _userDao = new UserDao(unitOfWork); }
public ActionResult Edit(int id) { var dao = new MenuDao(); var menu = dao.GetByID(id); return(View()); }
public ActionResult Create([Bind(Include = "ID,Text,Link,Status,Target")] Menu menu) { try { if (ModelState.IsValid) { var dao = new MenuDao(); menu.Text = menu.Text; menu.Link = menu.Link; menu.Target = menu.Target; menu.Status = Convert.ToBoolean(true); var id = dao.Insert(menu); if (id > 0) { SetAlert("Thêm mới thành thành công", "success"); ViewBag.Success = "Thêm thành công"; menu = new Menu(); return(RedirectToAction("Index", "Menu")); } else { ModelState.AddModelError("", "Thêm mới ko thành công"); } } } catch (DbEntityValidationException e) { throw e; } catch (Exception ex) { throw ex; } return(View(menu)); }
public ActionResult Edit(int Id) { var dao = new MenuDao(); Menu menu = dao.getMenuById(Id); return(View(menu)); }
public static IList <MenuInfo> GetMenus(ClientType clientType) { IList <MenuInfo> list = new List <MenuInfo>(); MenuDao menuDao = new MenuDao(); IList <MenuInfo> topMenus = menuDao.GetTopMenus(clientType); IList <MenuInfo> result; if (topMenus == null) { result = list; } else { foreach (MenuInfo current in topMenus) { list.Add(current); IList <MenuInfo> menusByParentId = menuDao.GetMenusByParentId(current.MenuId, clientType); if (menusByParentId != null) { foreach (MenuInfo current2 in menusByParentId) { list.Add(current2); } } } result = list; } return(result); }
// GET: Admin/Menu public ActionResult Index() { var dao = new MenuDao(); var model = dao.ListMenu(); return(View(model)); }
public async Task <IViewComponentResult> InvokeAsync() { ViewBag.Login = CommonConstants.USER_SESSION; var model = new MenuDao().ListByGroupId(); return(View(model)); }
public ActionResult TopMenu() { string lang = HttpContext.Session["CurrentCulture"].ToString(); var model = new MenuDao().ListByGroupId(2, lang); return(PartialView(model)); }
public void Page_Load(object sender, EventArgs e) { if (!Main.Instance.AdminApi.IsPluginAuthorized) { HttpContext.Current.Response.Write("<h1>未授权访问</h1>"); HttpContext.Current.Response.End(); return; } int.TryParse(Request.QueryString["parentId"], out _parentId); int.TryParse(Request.QueryString["menuId"], out _menuId); _menuInfo = _menuId > 0 ? MenuDao.GetMenuInfo(_menuId) : new MenuInfo(); if (IsPostBack) { return; } TbTitle.Text = _menuInfo.Title; if (_parentId > 0) { PhSettings.Visible = true; TbUrl.Text = _menuInfo.Url; Utils.SelectListItems(DdlIsOpenWindow, _menuInfo.IsOpenWindow.ToString()); } else { PhSettings.Visible = false; } BtnReturn.Attributes.Add("onclick", $"location.href='{PageMenu.GetRedirectUrl()}';return false"); }
public ActionResult MainMenu() { string lang = HttpContext.Session["CurrentCulture"].ToString(); var list = new MenuDao().ListByGroupId(1, lang); return(PartialView(list)); }
public ActionResult Edit(long id) { var dao = new MenuDao(); var menu = dao.GetById(id); return(View(menu)); }
public ActionResult Edit(int id) { var model = new MenuDao().ViewDetail(id); SetViewBag(model.IDMenu); return(View(model)); }
public ActionResult Edit([Bind(Include = "ID,Text,Link,Target,Status")] Menu menu) { try { if (ModelState.IsValid) { var dao = new MenuDao(); menu.Text = menu.Text; menu.Link = menu.Link; menu.Target = menu.Target; menu.Status = Convert.ToBoolean(true); var result = dao.Update(menu); if (result) { SetAlert("Sửa thành công", "success"); ViewBag.Success = "Cập nhật thành công"; menu = new Menu(); return(RedirectToAction("Index", "Menu")); } else { ModelState.AddModelError("", "Cập nhật ko thành công"); } } } catch (DbEntityValidationException e) { throw e; } catch (Exception ex) { throw ex; } return(View(menu)); }
public List<Menu> GetAllMenu() { ISqlMapper mapper = Common.GetMapperFromSession(); MenuDao dao = new MenuDao(mapper); List<Menu> list = TableCacheHelper.GetDataFromCache<Menu>(typeof(MenuDao)); return list; }
public LoginResultForm Login(string username, string password) { LoginResultForm result = new LoginResultForm(); ISqlMapper mapper = MapperHelper.GetMapper(); UserDao userdao = new UserDao(mapper); UserInfoDao userInfoDao = new UserInfoDao(mapper); RoleDao roleDao = new RoleDao(mapper); User_RoleDao urdao = new User_RoleDao(mapper); LogonHistoryDao historyDao = new LogonHistoryDao(mapper); MenuDao menudao = new MenuDao(mapper); Menu_RoleDao mrdao = new Menu_RoleDao(mapper); var user = userdao.Query(new UserQueryForm { Name = username, Password = password }).FirstOrDefault(); if (user != null) { if (user.Enabled == 0) throw new Exception("该用户已被禁用,请联系管理员!"); string token = Guid.NewGuid().ToString().Replace("-", ""); var userinfo = userInfoDao.Query(new UserInfoQueryForm { ID = user.ID }).FirstOrDefault(); var ur = urdao.Query(new User_RoleQueryForm { UserID = user.ID }); List<string> roleidlist = new List<string>(); ur.ForEach(t => { roleidlist.Add(t.RoleID); }); var roles = roleDao.Query(new RoleQueryForm { IDs = roleidlist }); var mrs = mrdao.Query(new Menu_RoleQueryForm { RoleIDs = roleidlist }); var menuids = (from mr in mrs select mr.MenuID).Distinct().ToList(); result.Menu = menudao.Query(new MenuQueryForm { IDs = menuids, Enabled = 1 }); UserEntireInfo u = new UserEntireInfo { User = user, UserInfo = userinfo, Role = roles, }; CacheItem item = new CacheItem(token, u); LogonHistory history = new LogonHistory { LogonTime = DateTime.Now, Token = token, UserID = user.ID, ActiveTime = DateTime.Now, }; historyDao.Add(history); result.User = u; result.token = token; cache.AddItem(item, 1800); //MonitorCache.GetInstance().PushMessage(new CacheMessage { Message = "login user:"******",token:" + token }, SOAFramework.Library.CacheEnum.FormMonitor); return result; } else { throw new Exception("用户名或者密码错误!请输入正确的用户名和密码!"); } }
/// <summary> /// 查询角色 /// </summary> /// <param name="form"></param> /// <returns></returns> public List<FullRoleInfo> QueryFullRole(RoleQueryForm form) { ISqlMapper mapper = MapperHelper.GetMapper(); RoleDao dao = new RoleDao(mapper); Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper); Menu_RoleDao mrdao = new Menu_RoleDao(mapper); MenuDao menudao = new MenuDao(mapper); List<FullRoleInfo> result = new List<FullRoleInfo>(); form.IsDeleted = 0; var roles = dao.Query(form); var roleids = (from r in roles select r.ID).ToList(); var rmas = rmadao.Query(new Role_Module_ActionQueryForm { RoleIDs = roleids }); var mrs = mrdao.Query(new Menu_RoleQueryForm { RoleIDs = roleids }); var menuids = (from mr in mrs select mr.MenuID).Distinct().ToList(); var menus = menudao.Query(new MenuQueryForm { IDs = menuids, Enabled = 1 }); AuthorityMapping mapping = XMLHelper.DeserializeFromFile<AuthorityMapping>(Common.AuthorityMappingFile); foreach (var role in roles) { var data = role.ConvertTo<FullRoleInfo>(); var parentrole = roles.Find(t => t.ID == role.ParentID); if (parentrole != null) data.ParentRoleName = parentrole.Name; #region 查询权限 var role_rmas = rmas.FindAll(t => t.RoleID.Equals(role.ID)); data.Authority = new List<AuthorityNodeForCheck>(); foreach (var auth in mapping.AuthNode) { auth.Checked = (from au in auth.Item from r in role_rmas where au.ModuleID == r.ModuleID && au.ActionID == r.ActionID select au).Count() == auth.Item.Count; data.Authority.Add(new AuthorityNodeForCheck { ID = auth.ID, Checked = auth.Checked, Name = auth.Name }); } #endregion #region 查询菜单 data.Menus = (from mr in mrs join m in menus on mr.MenuID equals m.ID where mr.RoleID.Equals(role.ID) select m).ToList(); #endregion result.Add(data); } return result; }
public List<Menu> Query(MenuQueryForm form) { ISqlMapper mapper = MapperHelper.GetMapper(); MenuDao dao = new MenuDao(mapper); return dao.Query(form); }