Пример #1
0
        public bool Create(RoleMenu obj)
        {
            bool isSuccess = false;

            try
            {
                isSuccess = true;
                _RoleMenuRepository.Add(obj);
                Save();
            }
            catch (Exception ex)
            {
                isSuccess = false;
                throw ex;
            }
            return(isSuccess);
        }
Пример #2
0
        public IActionResult SetMenuPermissions([FromBody] SetMenuPermissionVModel model)
        {
            var result = new ResultModel();

            return(this.Wrapper(ref result, () => {
                _roleMenuRepository.DeleteByRoleId(model.roleId);

                var roleMenus = new List <RoleMenu>();
                model.menuIds?.ForEach(ea => {
                    roleMenus.Add(new RoleMenu()
                    {
                        RoleId = model.roleId,
                        MenuId = ea
                    });
                });
                if (roleMenus?.Any() ?? false)
                {
                    _roleMenuRepository.Add(roleMenus);
                }
            }, true));
        }