Example #1
0
        public IEnumerable <Menu> SearchAddedInOpration(IConnectionHandler connectionHandler, Guid operationId, string value)
        {
            var predicateBuilder = new PredicateBuilder <Menu>();
            var guids            = new OperationMenuBO().Select(connectionHandler, x => x.MenuId, x => x.OperationId == operationId, true);

            if (guids.Any())
            {
                predicateBuilder.And(x => x.Id.In(guids));
            }
            predicateBuilder.And(x => x.Enabled);
            if (!string.IsNullOrEmpty(value))
            {
                predicateBuilder.And(x => x.Url.Contains(value) || x.Title.Contains(value));
            }
            return(this.OrderBy(connectionHandler, x => x.Order, predicateBuilder.GetExpression()));
        }
Example #2
0
        public bool Update(IConnectionHandler connectionHandler, MenuGroup menuGroup, List <Guid> menulistId)
        {
            if (!base.Update(connectionHandler, menuGroup))
            {
                throw new Exception("خطا درذخیره دسته بندی منو وجود دارد");
            }
            var menuBo     = new MenuBO();
            var enumerable =
                new OperationMenuBO().GetOprationMenu(connectionHandler, menuGroup.OperationId, menuGroup.Id);

            foreach (var guid in menulistId)
            {
                var menu = menuBo.Get(connectionHandler, guid);
                if (menu == null || menu.MenuGroupId == menuGroup.Id)
                {
                    continue;
                }
                menu.MenuGroupId = menuGroup.Id;
                if (!menuBo.Update(connectionHandler, menu))
                {
                    throw new Exception("خطا درذخیره دسته بندی منو وجود دارد");
                }
            }
            foreach (var menu in enumerable)
            {
                if (menulistId.Any(x => x == menu.Id))
                {
                    continue;
                }
                menu.MenuGroupId = null;
                if (!menuBo.Update(connectionHandler, menu))
                {
                    throw new Exception("خطا درذخیره دسته بندی منو وجود دارد");
                }
            }
            return(true);
        }