Exemplo n.º 1
0
        public virtual IList <AutoImportCategoryPermission> GetAutoimportPermissionsByCategoryIdList(IEnumerable <int> categoryIds)
        {
            using (var session = GetSession())
            {
                AutoImportCategoryPermission autoimportPermissionAlias = null;
                Category categoryAlias = null;

                var permissions = session.QueryOver(() => autoimportPermissionAlias)
                                  .JoinQueryOver(x => autoimportPermissionAlias.Category, () => categoryAlias)
                                  .AndRestrictionOn(() => categoryAlias.Id).IsInG(categoryIds)
                                  .List <AutoImportCategoryPermission>();

                return(permissions);
            }
        }
Exemplo n.º 2
0
        protected override void ProcessElement(BookVersion bookVersion, Category parentCategory, XmlReader xmlReader)
        {
            string xmlId    = xmlReader.GetAttribute("xml:id");
            var    category = m_categoryRepository.FindByXmlId(xmlId);

            if (category == null)
            {
                category = new Category
                {
                    XmlId          = xmlId,
                    ParentCategory = parentCategory
                };

                if (parentCategory != null)
                {
                    category.BookType = parentCategory.BookType;
                    category.Path     = string.Format("{0}{1}/", parentCategory.Path, xmlId);
                }
                else
                {
                    category.Path = string.Format("/{0}/", xmlId);
                }

                m_categoryRepository.SaveOrUpdate(category);
                var newlyCreatedCategory    = m_categoryRepository.FindByXmlId(category.XmlId);
                var newAutoimportPermission = new AutoImportCategoryPermission
                {
                    Category            = newlyCreatedCategory,
                    AutoImportIsAllowed = true
                };
                m_permissionRepository.CreateSpecialPermission(newAutoimportPermission);
            }

            base.ProcessElement(bookVersion, category, xmlReader);
            m_categoryRepository.SaveOrUpdate(category);
        }