コード例 #1
0
        public Article CreateModel(ArticleDTO articleDto)
        {
            var      article    = _data.CreateModel(articleDto);
            Category categories = _unitOfWork.CategoryRepository.Find(q => q.Name == articleDto.Category.Name).ToList().FirstOrDefault();

            article.Category = categories ?? CategoryMapper.MapCategory(articleDto.Category);
            return(article);
        }
コード例 #2
0
        /// <summary>
        /// Return all categories
        /// </summary>
        /// <returns></returns>
        public IEnumerable <Category> GetAll()
        {
            const string cacheKey = "GetAllCategories";

            return((IEnumerable <Category>)ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem(cacheKey, () =>
            {
                return CategoryMapper.MapCategory(_forumRootNode.Descendants(DialogueConfiguration.Instance.DocTypeForumCategory).ToList());
            }));
        }
コード例 #3
0
        public override ActionResult Index(RenderModel model)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // Get the category
                var category = CategoryMapper.MapCategory(model.Content, true);

                // Set the page index
                var pageIndex = AppHelpers.ReturnCurrentPagingNo();

                // check the user has permission to this category
                var permissions = ServiceFactory.PermissionService.GetPermissions(category, _usersRoles);

                if (!permissions[AppConstants.PermissionDenyAccess].IsTicked)
                {
                    var topics = ServiceFactory.TopicService.GetPagedTopicsByCategory(pageIndex,
                                                                                      Settings.TopicsPerPage,
                                                                                      int.MaxValue, category.Id);

                    var isSubscribed = UserIsAuthenticated && (ServiceFactory.CategoryNotificationService.GetByUserAndCategory(CurrentMember, category).Any());

                    // Create the main view model for the category
                    var viewModel = new ViewCategoryViewModel(model.Content)
                    {
                        Permissions  = permissions,
                        Topics       = topics,
                        Category     = category,
                        PageIndex    = pageIndex,
                        TotalCount   = topics.TotalCount,
                        User         = CurrentMember,
                        IsSubscribed = isSubscribed
                    };

                    // If there are subcategories then add then with their permissions
                    if (category.SubCategories.Any())
                    {
                        var subCatViewModel = new CategoryListViewModel
                        {
                            AllPermissionSets = new Dictionary <Category, PermissionSet>()
                        };
                        foreach (var subCategory in category.SubCategories)
                        {
                            var permissionSet = ServiceFactory.PermissionService.GetPermissions(subCategory, _usersRoles);

                            subCategory.LatestTopic = ServiceFactory.TopicService.GetPagedTopicsByCategory(1, Settings.TopicsPerPage, int.MaxValue, subCategory.Id).FirstOrDefault();
                            subCategory.TopicCount  = ServiceFactory.TopicService.GetTopicCountByCategory(subCategory.Id);
                            subCatViewModel.AllPermissionSets.Add(subCategory, permissionSet);
                        }
                        viewModel.SubCategories = subCatViewModel;
                    }

                    return(View(PathHelper.GetThemeViewPath("Category"), viewModel));
                }

                return(ErrorToHomePage("No Permission"));
            }
        }
コード例 #4
0
        public void PopulateCategories(IList <Topic> entityList)
        {
            // Map full categories
            var catIds = entityList.Select(x => x.CategoryId).ToList();
            var cats   = CategoryMapper.MapCategory(catIds);

            foreach (var entity in entityList)
            {
                var cat = cats.FirstOrDefault(x => x.Id == entity.CategoryId);
                entity.Category = cat;
            }
        }
コード例 #5
0
        public List <Category> Get(List <int> ids)
        {
            var cats = new List <Category>();

            if (ids.Any())
            {
                var allCats = AppHelpers.UmbHelper().TypedContent(ids);
                foreach (var cat in allCats)
                {
                    cats.Add(CategoryMapper.MapCategory(cat));
                }
            }
            return(cats);
        }
コード例 #6
0
 public async Task <ActionResult <IEnumerable <V1DTO.Category> > > GetCategoriesWithRestaurants()
 {
     return(Ok((await _bll.Categories.GetAllAsync()).Select(e => _mapper.MapCategory(e))));
 }
コード例 #7
0
 /// <summary>
 /// Get all main categories (Categories with no parent category)
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Category> GetAllMainCategories()
 {
     return(CategoryMapper.MapCategory(_forumRootNode.Descendants(DialogueConfiguration.Instance.DocTypeForumCategory)
                                       .Where(x => x.Parent.DocumentTypeAlias != DialogueConfiguration.Instance.DocTypeForumCategory).ToList()));
 }
コード例 #8
0
 public Category Get(int id, bool getSubAndParentCats = false)
 {
     return(CategoryMapper.MapCategory(AppHelpers.GetNode(id), getSubAndParentCats));
 }
コード例 #9
0
 /// <summary>
 /// Get all main categories (Categories with no parent category)
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Category> GetAllMainCategories()
 {
     return(CategoryMapper.MapCategory(_forumRootNode.Descendants(AppConstants.DocTypeForumCategory)
                                       .Where(x => x.Parent.DocumentTypeAlias != AppConstants.DocTypeForumCategory).ToList()));
 }
コード例 #10
0
 /// <summary>
 /// Return all categories
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Category> GetAll()
 {
     return(CategoryMapper.MapCategory(_forumRootNode.Descendants(AppConstants.DocTypeForumCategory).ToList()));
 }