Пример #1
0
        public ArticlePageViewModel CreateEventListModel(ArticlePageViewModel articlePageViewModel)
        {
            ArticlePageViewModel articleDetailModel = new ArticlePageViewModel();
            ArticleBll           acBll = new ArticleBll();

            articleDetailModel.page_size        = 20;
            articleDetailModel.page_index       = articlePageViewModel.page_index;
            articleDetailModel.articleRightList = acBll.GetEventPageList(new ArticlePageViewModel {
                article_state = 1, page_index = 1, page_size = 15, category_id = articlePageViewModel.category_id
            });
            articleDetailModel.category_id     = articlePageViewModel.category_id;
            articleDetailModel.articlePageList = acBll.GetEventPageList(articleDetailModel);

            ArticleCategoryBll categoryBll = new ArticleCategoryBll();

            articleDetailModel.ThisArticleCategory = categoryBll.GetCategory(new ArticleCategory {
                category_id = articlePageViewModel.ThisArticleCategory.category_id
            });
            articleDetailModel.ThisArticleFatherCategory = categoryBll.GetCategory(new ArticleCategory {
                category_id = articlePageViewModel.ThisArticleCategory.category_father_id
            });
            articleDetailModel.ArticleCategoryList = categoryBll.GetCategoryList(new ArticleCategory {
                category_father_id = articleDetailModel.ThisArticleCategory.category_father_id
            });
            return(articleDetailModel);
        }
Пример #2
0
        public ActionResult Article(string category, string url)
        {
            ViewBag.HideTitle = true;
            Article article = repoArticle.Article(url: url);

            if (article != null)
            {
                User user = repoUser.User(email: repoSession.UserEmail);
                ArticlePageViewModel articlePageViewModel = new ArticlePageViewModel()
                {
                    Category           = article.Category,
                    Comments           = article.Comments,
                    ContentExternalUrl = repoConfig.Get(ConfigurationKeyStatic.CONTENT_EXTERNAL_URL),
                    HasUserNick        = !string.IsNullOrEmpty(repoSession.UserNick),
                    IsLogged           = repoSession.IsLogged,
                    Tags = article.Tags
                };
                ViewBag.Title = String.Format("{0} - {1}", article.Title, Resources.Article);
                if (article != null)
                {
                    ViewBag.Description = article.Lead;
                    ViewBag.Keywords    = String.Format("{0} - {1}", article.ImageDesc, Resources.Article);
                }
                return(View(articlePageViewModel));
            }
            else
            {
                this.SetMessage(InfoMessageType.Danger, Resources.ArticleNotFound);
                return(Redirect(Url.Action("Index", "Article")));
            }
        }
Пример #3
0
        internal PagedList <Article> GetZazhiPageList(ArticlePageViewModel articleDetailModel)
        {
            var articleList = articleDao.SelectPageList(articleDetailModel);//获取网站公告

            articleList.ForEach(t => t.article_click_url   = "/zazhi/zazhi_" + t.article_id + ".html");
            articleList.ForEach(t => t.article_description = string.IsNullOrEmpty(t.article_description) ? StringHelper.ReplaceHtmlTag(t.article_content, 200) : t.article_description);
            return(articleList);
        }
Пример #4
0
        public ActionResult Detail(int id = 0)
        {
            ArticlePageViewModel articlePageViewModel = new ArticlePageViewModel();
            ArticlePageBll       articlePageBll       = new ArticlePageBll();

            articlePageViewModel = articlePageBll.CreateArticleDetailModel(id, 1);
            return(View(articlePageViewModel));
        }
Пример #5
0
        internal PagedList <Article> GetArticlePageListOrderByNewId(ArticlePageViewModel articlePageViewModel)
        {
            var articleList = articleDao.SelectOrderByNewId(articlePageViewModel.page_size);//获取随机文章

            articleList.ForEach(t => t.article_click_url   = "/article/article_" + t.article_id + ".html");
            articleList.ForEach(t => t.article_description = string.IsNullOrEmpty(t.article_description) ? StringHelper.ReplaceHtmlTag(t.article_content, 200) : t.article_description);

            return(articleList);
        }
Пример #6
0
        public PagedList <Article> SelectPageList(ArticlePageViewModel articleDetailModel)
        {
            var query = db.Article.Where(t =>
                                         (string.IsNullOrEmpty(articleDetailModel.user_id) || t.article_kuser == articleDetailModel.user_id) &&
                                         (articleDetailModel.category_id == 0 || t.category_id == articleDetailModel.category_id) &&
                                         (articleDetailModel.article_state == 0 || t.article_state == articleDetailModel.article_state) &&
                                         (articleDetailModel.article_id == 0 || t.article_id == articleDetailModel.article_id)).OrderBy(t => t.article_sort).OrderByDescending(s => s.article_mdate);

            return(query.ToPagedList <Article>(articleDetailModel.page_index, articleDetailModel.page_size));
        }
Пример #7
0
        public ActionResult Index()
        {
            var viewModel = new ArticlePageViewModel
            {
                Title    = "Articles",
                Articles = GetAllArticles()
            };

            return(View(viewModel));
        }
Пример #8
0
        public ArticlePageViewModel CreateUserArticleListModel(ArticlePageViewModel articlePageViewModel)
        {
            ArticlePageViewModel articleDetailModel = new ArticlePageViewModel();
            ArticleBll           acBll = new ArticleBll();

            articleDetailModel.page_size  = 200;
            articleDetailModel.page_index = articlePageViewModel.page_index;

            articleDetailModel.category_id     = articlePageViewModel.category_id;
            articleDetailModel.user_id         = articlePageViewModel.user_id;
            articleDetailModel.articlePageList = acBll.GetArticlePageList(articleDetailModel);


            return(articleDetailModel);
        }
Пример #9
0
        public ActionResult List(int pageindex = 1, int cid = 0)
        {
            if (cid > 1)
            {
                Session["category_id"] = cid;
            }
            if (pageindex == null || pageindex < 0)
            {
                pageindex = 0;
            }
            ArticlePageViewModel articlePageViewModel = new ArticlePageViewModel();
            ArticlePageBll       articlePageBll       = new ArticlePageBll();

            articlePageViewModel.page_index                      = pageindex;
            articlePageViewModel.ThisArticleCategory             = new ArticleCategory();
            articlePageViewModel.ThisArticleCategory.category_id = Convert.ToInt32(Session["category_id"]);
            articlePageViewModel.category_id                     = Convert.ToInt32(Session["category_id"]);
            articlePageViewModel = articlePageBll.CreateEventListModel(articlePageViewModel);
            return(View(articlePageViewModel));
        }
Пример #10
0
        public ActionResult New(ArticlePageViewModel viewModel)
        {
            Article article = null;

            using (PortalContext context = new PortalContext())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (viewModel.Id.HasValue)
                        {
                            article         = context.Articles.FirstOrDefault(x => x.Id == viewModel.Id.Value);
                            article.Title   = viewModel.Title;
                            article.Content = viewModel.Content;
                            context.SaveChanges();
                        }
                        else
                        {
                            article = context.Articles.Add(viewModel.Article());
                            context.SaveChanges();
                        }
                        // context.ArticlePages.Add(viewModel.Page());

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                    }
                }
            }
            if (article.Id != 0)
            {
                return(RedirectToAction("New", new { id = article.Id }));
            }
            else
            {
                return(View(new ArticlePageViewModel(article: article)));
            }
        }
Пример #11
0
        public ArticlePageViewModel CreateArticleDetailModel(int article_id, int type = 0)
        {
            ArticlePageViewModel articleDetailModel = new ArticlePageViewModel();

            try
            {
                ArticleBll acBll = new ArticleBll();
                Article    ac    = new Article();
                ac.article_id = article_id;
                Article acNew = acBll.GetArticle(ac);

                articleDetailModel.articleModel = acNew;

                ArticleCategoryBll acateBll = new ArticleCategoryBll();
                articleDetailModel.ThisArticleCategory       = acBll.GetArticleCategoryByArticle(article_id);
                articleDetailModel.ThisArticleFatherCategory = acBll.GetArticleFatherCategoryByArticle(article_id);
                if (0 == type)
                {
                    articleDetailModel.articleRightList = acBll.GetArticlePageList(new ArticlePageViewModel {
                        category_id = acNew.category_id, article_state = 1, page_index = 1, page_size = 20
                    });
                }
                if (1 == type)
                {
                    articleDetailModel.articleRightList = acBll.GetEventArticlePageList(new ArticlePageViewModel {
                        category_id = acNew.category_id, article_state = 1, page_index = 1, page_size = 20
                    });
                }
                if (2 == type)
                {
                    articleDetailModel.articleRightList = acBll.GetZazhiArticlePageList(new ArticlePageViewModel {
                        category_id = acNew.category_id, article_state = 1, page_index = 1, page_size = 20
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(articleDetailModel);
        }
        public ViewResult Article(Guid articleId)
        {
            var article = _repository.Articles.SingleOrDefault(a => a.ArticleId == articleId);

            if (article == null)
            {
                throw new NullReferenceException("Статья не найдена!");
            }

            var articleViewModel = new ArticlePageViewModel
            {
                ArticleId     = articleId,
                Name          = article.Name,
                Content       = article.Content,
                Description   = article.Description,
                ContentImages = article.ImagesData.ToList(),
                Tags          = article.Tags
            };

            return(View(articleViewModel));
        }
Пример #13
0
        public ActionResult UserIndexArticle(int pageindex = 1, int cid = 0)
        {
            if (cid > 1)
            {
                Session["category_id"] = cid;
            }
            if (pageindex == null || pageindex < 0)
            {
                pageindex = 0;
            }
            ArticlePageViewModel articlePageViewModel = new ArticlePageViewModel();
            ArticlePageBll       articlePageBll       = new ArticlePageBll();

            articlePageViewModel.page_index                      = pageindex;
            articlePageViewModel.ThisArticleCategory             = new ArticleCategory();
            articlePageViewModel.ThisArticleCategory.category_id = 0;
            articlePageViewModel.category_id                     = 0;
            articlePageViewModel.user_id = Session["user_id"].ToString();
            articlePageViewModel         = articlePageBll.CreateUserArticleListModel(articlePageViewModel);
            return(View(articlePageViewModel));
        }
Пример #14
0
        public ArticlePageViewModel CreateArticleListModel(ArticlePageViewModel articlePageViewModel)
        {
            ArticlePageViewModel articleDetailModel = new ArticlePageViewModel();
            ArticleBll           acBll = new ArticleBll();

            articleDetailModel.page_size        = 20;
            articleDetailModel.page_index       = articlePageViewModel.page_index;
            articleDetailModel.articleRightList = acBll.GetArticlePageListOrderByNewId(new ArticlePageViewModel {
                article_state = 1, page_index = 1, page_size = 20
            });
            articleDetailModel.category_id     = articlePageViewModel.category_id;
            articleDetailModel.articlePageList = acBll.GetArticlePageList(articleDetailModel);

            ArticleCategoryBll categoryBll = new ArticleCategoryBll();

            articleDetailModel.ThisArticleCategory = categoryBll.GetCategory(new ArticleCategory {
                category_id = articlePageViewModel.ThisArticleCategory.category_id
            });
            articleDetailModel.ThisArticleFatherCategory = categoryBll.GetCategory(new ArticleCategory {
                category_id = articleDetailModel.ThisArticleCategory.category_father_id
            });

            articleDetailModel.ArticleCategoryList = categoryBll.GetCategoryList(new ArticleCategory {
                category_father_id = articleDetailModel.ThisArticleCategory.category_father_id
            });

            if (articleDetailModel.ThisArticleFatherCategory.category_level > 2)
            {
                //ArticleCategory acFather  =  categoryBll.GetCategory(new ArticleCategory { category_id = articleDetailModel.ThisArticleFatherCategory.category_father_id });
                articleDetailModel.FatherBrotherCategoryList = categoryBll.GetCategoryList(new ArticleCategory {
                    category_father_id = articleDetailModel.ThisArticleFatherCategory.category_father_id, category_level = 2, category_id = articleDetailModel.ThisArticleFatherCategory.category_id
                });
            }


            return(articleDetailModel);
        }
Пример #15
0
        public ArticlePage()
        {
            this.InitializeComponent();

            this.SetValue(NavProperties.HeaderProperty, ResourceLoader.GetForCurrentView().GetString("Article"));

            var headerButtons = new ObservableCollection <object>();
            var shareButton   = new AppBarButton
            {
                Label = ResourceLoader.GetForCurrentView().GetString("Share"),
                Icon  = new SymbolIcon {
                    Symbol = (Symbol)Enum.Parse(typeof(Symbol), "Share")
                },
                Command = ViewModel.ShareButtonCommand
            };

            headerButtons.Add(shareButton);
            SetValue(NavProperties.HeaderCommandsProperty, headerButtons);

            this.Unloaded += (sender, e) =>
            {
                ViewModel = null;
            };
        }
Пример #16
0
        public ArticlePageViewModel GetArticlePageViewModel(int currentUmbracoPageId)
        {
            var _currentArticle = _umbracoHelper.TypedContent(currentUmbracoPageId);

            var _model = new ArticlePageViewModel();

            _model.ArticleContent = new ArticleContent(_currentArticle);

            #region Pobranie Regionu i typu artykułu
            var _regionFilterItemsFromDB = _dbService.GetAll <RegionDB>("PolRegioRegion", q => q.IsEnabled);

            if (_currentArticle.DocumentTypeAlias == DocumentTypeEnum.articleWithFilter.ToString())
            {
                var _artilceWithFiltr = new ArticleWithFilter(_currentArticle);
                if (_artilceWithFiltr.RegionFiltr != null)
                {
                    var _articleRegion = JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(_artilceWithFiltr.RegionFiltr.SavedValue.ToString()).FirstOrDefault();
                    if (_articleRegion != null)
                    {
                        var _regionFromDb = _regionFilterItemsFromDB.Where(q => q.Id.ToString() == _articleRegion.Key).FirstOrDefault();
                        if (_regionFromDb != null)
                        {
                            _model.ArticleRegion = _umbracoHelper.GetDictionaryValue(_regionFromDb.DictionaryKey);
                        }
                    }
                }
            }

            if (_currentArticle.DocumentTypeAlias == DocumentTypeEnum.articleWithDoubleFiltr.ToString())
            {
                var _artilceWithFiltr = new ArticleWithDoubleFiltr(_currentArticle);
                if (_artilceWithFiltr.ArticleCategory != null)
                {
                    var _articleType = JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(_artilceWithFiltr.ArticleCategory.SavedValue.ToString()).FirstOrDefault();
                    _model.ArticleType = Enum.Parse(typeof(ArticleTypeEnum), _articleType.Key).ToString();
                }
                if (_artilceWithFiltr.ArticleRegions != null)
                {
                    var _articleRegion = JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(_artilceWithFiltr.ArticleRegions.SavedValue.ToString()).FirstOrDefault();
                    if (_articleRegion != null)
                    {
                        var _regionFromDb = _regionFilterItemsFromDB.Where(q => q.Id.ToString() == _articleRegion.Key).FirstOrDefault();
                        if (_regionFromDb != null)
                        {
                            _model.ArticleRegion = _umbracoHelper.GetDictionaryValue(_regionFromDb.DictionaryKey);
                        }
                    }
                }
            }
            #endregion

            #region Galeria
            if (_model.ArticleContent.ArticleImageList != null)
            {
                _model.CarouselImages = _model.ArticleContent.ArticleImageList.Fieldsets.Where(x => x != null && x.Properties.Any() && !x.Disabled).Select(q => new ArticleCarouselItem()
                {
                    ArticleCarouselImage = q.GetValue <string>("addImage"),
                    ArticleCarouselDesc  = q.GetValue <string>("imageCarouselDesc"),
                    ArticleCarouselName  = q.GetValue <string>("imageName")
                });
            }
            #endregion

            #region Dokumenty
            if (_model.ArticleContent.AddDocumentDown != null)
            {
                _model.DownloadDocuments = _model.ArticleContent.AddDocumentDown.Fieldsets.Where(x => x != null && x.Properties.Any() && !x.Disabled).Select(q => new DownloadItem()
                {
                    DocumentUrl  = q.GetValue <string>("addDoc"),
                    DocumentName = q.GetValue <string>("articleDocName"),
                    DocumentDate = q.GetValue <DateTime>("chooseDate")
                });
            }
            #endregion
            #region Tags
            if (_model.ArticleContent.ArticleTag != null)
            {
                var _localizationNode = _currentArticle.AncestorOrSelf(DocumentTypeEnum.location.ToString());
                var nodes             = _localizationNode.Descendant(DocumentTypeEnum.articleListWithTag.ToString());

                IPublishedContent node = _umbracoHelper.TypedContent(nodes.Id);
                _model.TagListUrl = node.Url;


                var tagItem = _model.ArticleContent.ArticleTag.ToString().Split(',');
                _model.Tags = tagItem;
            }
            #endregion

            #region Data
            var _boxArticle = new ArticleBox(_currentArticle);
            if (_boxArticle != null && _boxArticle.ListArticleDate != DateTime.MinValue)
            {
                _model.ArticleDate = _boxArticle.ListArticleDate;
            }
            #endregion

            #region Sprawdzenie czy oferta czy informacja
            var _articleParent = _currentArticle.AncestorOrSelf(DocumentTypeEnum.OffersAndPromotions.ToString());
            if (_articleParent != null)
            {
                _model.IsOffersArticle = true;
            }
            #endregion
            return(_model);
        }
Пример #17
0
        public ActionResult Index(ArticlePage currentPage)
        {
            var model = new ArticlePageViewModel();

            return(View(model));
        }