public ActionResult Edit(long id = 0)
        {
            if (id == 0)
            {
                return(View(new FuncBtn()));
            }
            var info = FuncBtnBll.GetById(id);

            return(View(info));
        }
        public ActionResult Delete(long id)
        {
            var apiResult = new APIResult();

            try
            {
                FuncBtnBll.DeleteById(id);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }
            return(Json(apiResult));
        }
        public JsonResult Edit(Hotel.Model.FuncBtn model)
        {
            var apiResult = new APIResult();

            try
            {
                FuncBtnBll.AddOrUpdate(model);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }

            return(Json(apiResult));
        }
        public string GetList()
        {
            var pager = FuncBtnBll.GetList();

            return(JsonConvert.SerializeObject(pager));
        }
Esempio n. 5
0
        public JsonResult SaveAuth(long groupId, GroupAuthModel[] models)
        {
            var apiResult = new APIResult();

            if (groupId == 1)
            {
                apiResult.Ret = -1;
                apiResult.Msg = "不可设置平台管理员权限";
                return(Json(apiResult));
            }
            List <GroupAuthority> authList = new List <GroupAuthority>();

            if (models.Length == 0)
            {
                apiResult.Ret = -1;
                apiResult.Msg = "请选择权限";
                return(Json(apiResult));
            }
            //获取所有菜单
            var menuList = MenuBll.GetMenus();
            //获取所有按钮
            var btnList = FuncBtnBll.GetList();

            try
            {
                foreach (var item in models)
                {
                    long menuId = item.id;
                    var  menu   = menuList.FirstOrDefault(m => m.Id == menuId);
                    if (menu == null)
                    {
                        continue;
                    }
                    string btnsStr = item.btnIdStr;
                    if (string.IsNullOrWhiteSpace(btnsStr))
                    {
                        continue;
                    }
                    string[] btnIdArray = btnsStr.Split(',');
                    if (btnIdArray.Length == 0)
                    {
                        continue;
                    }
                    foreach (var btnIdString in btnIdArray)
                    {
                        long btnId = 0;
                        if (long.TryParse(btnIdString, out btnId))
                        {
                            var funcBtn = btnList.FirstOrDefault(m => m.Id == btnId);
                            authList.Add(new GroupAuthority()
                            {
                                GroupId        = groupId,
                                MenuId         = menuId,
                                MenuController = menu.MenuController,
                                FuncBtnId      = funcBtn.Id,
                                FuncBtnName    = funcBtn.Name,
                                FuncBtnCode    = funcBtn.Code,
                                Seq            = funcBtn.Seq,
                                CDate          = TypeConvert.DateTimeToInt(DateTime.Now)
                            });
                        }
                    }
                }

                if (authList.Count == 0)
                {
                    GroupAuthorityBll.Delete(groupId);
                }
                else
                {
                    GroupAuthorityBll.Delete(groupId);
                    authList.ForEach(m => {
                        GroupAuthorityBll.AddOrUpdate(m);
                    });
                }
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }
            return(Json(apiResult));
        }