Пример #1
0
        public ActionResult MyList()
        {
            var articles      = articleService.GetByAuther(new ArticleGetByAutherQuery(myId()));
            var listViewModel = new ArticleListModel(articles);

            return(View(listViewModel));
        }
Пример #2
0
        public ActionResult ListFromIndex(string keyWord, int pageIndex = 1)
        {
            commonInfo.WirteLog("ListFromIndex开始时间");
            int           categoryId = 0;
            BookQueryData query      = new BookQueryData();

            query.CategoryIdOne  = (TypeEnum)categoryId;
            query.KeyWordOneSimp = keyWord;
            query.KeyWordOneOrig = FontTypeConvert.VBConvertOrig(keyWord);
            commonInfo.WirteLog("ListFromIndex简繁转换");
            int            count    = 0;
            List <TB_Book> bookList = _bookService.GetBookListByQueryData(query, out count, pageIndex, pageSize).ToList();

            commonInfo.WirteLog("ListFromIndex书籍List");
            List <BookViewModel> models = GetQueryList(bookList);

            commonInfo.WirteLog("ListFromIndex列表分页");
            s_keyWord    = keyWord;
            s_categoryId = 0;
            ArticleListModel articleModel = new ArticleListModel();

            articleModel.CategoryId       = 0;
            articleModel.KeyFan           = FontTypeConvert.VBConvertOrig(keyWord);
            articleModel.KeyJian          = FontTypeConvert.VBConvertSimp(keyWord);
            articleModel.KeyWord          = keyWord;
            articleModel.BooViewModelList = models;
            articleModel.CurrentPageIndex = pageIndex;
            articleModel.Count            = count;
            articleModel.PageSize         = pageSize;
            articleModel.PageTotalCount   = count % pageSize == 0 ? count / pageSize : (int)Math.Ceiling((double)(count / pageSize)) + 1;
            commonInfo.WirteLog("ListFromIndex列表结束");
            return(View("List", articleModel));
        }
        public IActionResult GetArticleByName(CategoryModel model)
        {
            var response = _categoryService.GetArticleByName(model.Name);
            var articles = new ArticleListModel();

            if (response.Success)
            {
                if (response.Extra != null)
                {
                    articles.Articles = response.Extra.Articles;
                    articles.Category = response.Extra;
                }
                else
                {
                    _message.Content = "Bu Kategoriye Ait Kayıtlı Makale Bilgisi Bulunamadı";
                    _message.Css     = "warning";
                }
            }
            else if (response.ErrorMessageCode == new MessageCode().ErrorCreated)
            {
                _message.Content = "Makale Listesi Getirilirken Bir Hata Meydana Geldi Lütfen Daha Sonra Tekrar deneyiniz";
            }
            ViewData["Message"] = _message;
            return(View(articles));
        }
Пример #4
0
        //public ActionResult Index()
        //{
        //    return View();
        //}

        //public ActionResult ArticleTest(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, string articleName)
        //{

        //    return View();
        //}

        //public ActionResult ArticleList1(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, int? page)
        //{

        //    return View();
        //}

        public ActionResult ArticleListRoot(string articleType, int?page)
        {
            ArticleListModel model = new ArticleListModel();

            PageModel.Title       = "";
            PageModel.Description = "";
            PageModel.Author      = "";
            PageModel.Keywords    = "";

//            string url = HttpContext.Request.RawUrl;
            //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", "");

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                //BASED ON CAT
                //mo
                model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleType.ArticleTypeName == articleType && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);

                //CHECK PAGING
                //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 1);
                //model.PagedArticle = model.ArticleList.Concat(db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleTypeId == 2)).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);
            }
            //model.PagedArticle = model.ArticleList.ToPagedList(page ?? 1, pageSize);
            return(View(model));
        }
Пример #5
0
        public async Task <IActionResult> Search([FromQuery] string title)
        {
            // this is a bad practice that we try to match a keyword within data with a cloumn about 32000 capacity
            // we must use indexed data to provide high-quality search, for example using Lucene as a full-featured text search engine library
            var articles = await _articleRepository
                           .Query()
                           .AsNoTracking()
                           .Where(a => a.Title.Contains(title) || a.Content.Contains(title))
                           .Take(20)
                           .ToListAsync();

            var result = new ArticleListModel
            {
                Articles = articles.Select(a => new ArticleModel
                {
                    Id        = a.Id,
                    Title     = a.Title,
                    Content   = a.Content,
                    Date      = a.Date,
                    Published = a.Published
                })
            };

            return(Ok(result));
        }
Пример #6
0
        public ActionResult Index(int?page)
        {
            ArticleListModel model = new ArticleListModel();

            PageModel.Title       = "";
            PageModel.Description = "";
            PageModel.Author      = "";
            PageModel.Keywords    = "";

            //ListAccess la = new ListAccess();
            //model.MostViewed = la.MostViewed(11, 20);

            string url = HttpContext.Request.RawUrl;

            //int catigoryRowId = DIYFEHelper.GetCatigoryRowId(url);

            //model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(catigoryRowId, linkPrefix);
            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                // model.ProjectList = db.Articles.Where(a => a.ArticleTypeId == 2).OrderBy(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).ToList();
                //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).ToList();
                model.PagedArticle = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize);
            }

            //model.ArticleList = la.ArticleList(catigoryId, 1);

            return(View(model));
        }
Пример #7
0
        public ActionResult MyList()
        {
            var parameter     = new ArticleGetByAutherRequest(myId());
            var response      = bus.Handle(parameter);
            var listViewModel = new ArticleListModel(response.Articles);

            return(View(listViewModel));
        }
Пример #8
0
        /// <summary>
        /// GET 留言墙
        /// </summary>
        /// <returns></returns>
        public ActionResult LeavaMassage()
        {
            List <LeavaMessage> msg = db.Msg.OrderByDescending(q => q.MessageTime).Take(10).ToList();
            var model = new ArticleListModel();

            model.Msg = msg;
            return(View(model));
        }
Пример #9
0
        public IActionResult ArticleList(int page = 1, int size = 20, string keyword = null, bool?status = null)
        {
            var model = new ArticleListModel();

            model.Keyword  = keyword;
            model.Articles = DefaultStorage.ArticlePagedList(page, size, keyword, status);
            return(View(model));
        }
Пример #10
0
        public ActionResult Articles()
        {
            List <Article>   articles = _articleSrv.GetArticles();
            ArticleListModel model    = new ArticleListModel();

            model.Articles = _mapper.Map <List <ArticleDetailsModel> >(articles);

            return(View(model));
        }
Пример #11
0
        /// <summary>
        /// 微信素材库列表
        /// Author:WL
        /// </summary>
        public ActionResult List()
        {
            string           access_token  = WeiXinGetFunction();
            ArticleListModel newsListModel = new ArticleListModel();

            newsListModel = WeiXinPostFunction(access_token);
            SiteUtils.SetAdminRefererCookie(Url.Action("list"));
            return(View(newsListModel));
        }
Пример #12
0
        /// <summary>
        /// 后端技术文章
        /// </summary>
        /// <returns></returns>
        public ActionResult BackIndex()
        {
            List <Article> articleList = db.Article.Where(w => w.ArticleType == "1").OrderByDescending(q => q.ArticleClick).Take(10).ToList();
            var            articleNow  = db.Article.Where(w => w.SortArticleId == 1).Where(w => w.ArticleType == "1").OrderByDescending(q => q.ArticleTime).Take(10).ToList();
            var            model       = new ArticleListModel();

            model.ArtcleList = articleNow;
            model.ArtcileHot = articleList;
            return(View(model));
        }
Пример #13
0
        public ActionResult LeavaMassage(ArticleListModel model)
        {
            model.LeavaMsg.MessageTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            db.Msg.Add(model.LeavaMsg);
            db.SaveChanges();
            List <Article> articleList = db.Article.OrderByDescending(q => q.ArticleClick).Take(10).ToList();

            model.ArtcileHot = articleList;
            model.Msg        = db.Msg.ToList();
            return(View(model));
        }
Пример #14
0
        public ActionResult List(string articleTitle, string Keyword, string sortColumn, string sortDirection, int?articleClassId1, int pageSize = 10, int pageNumber = 1)
        {
            pageSize = WorkContext.SiteConfig.pageSize;
            int articleClassId = 0;

            if (articleClassId1 == null)
            {
                articleClassId = 233;
            }
            else
            {
                articleClassId = (int)articleClassId1;
            }

            ArticleClassInfo classInfo = ArticleClass.AdminGetModelById(articleClassId);

            //if (classInfo == null)
            //    return PromptView("文章分类不存在");

            ////管理菜单
            //if ((classInfo.ClassType.Equals(-1)) || (classInfo.ClassType.Equals(0)))
            //    Response.Redirect(classInfo.AdminUrl);
            ////单页
            //if (classInfo.ClassType.Equals(1))
            //    return RedirectToAction("Page", new { articleClassId = articleClassId });
            string condition = Article.AdminGetArticleListCondition(articleClassId, articleTitle);
            //string condition = " [Keyword] = 1 ";
            string    condition1 = condition + @" or [Keyword] = 1  ";
            string    sort       = Article.AdminGetArticleListSort(sortColumn, sortDirection);
            PageModel pageModel  = new PageModel(pageSize, pageNumber, Article.AdminGetArticleCount(condition1));
            //
            ArticleListModel model = new ArticleListModel()
            {
                DataList       = Article.AdminGetArticleList(pageModel.PageSize, pageModel.PageNumber, condition1, sort),
                PageModel      = pageModel,
                SortColumn     = sortColumn,
                SortDirection  = sortDirection,
                ArticleClassID = articleClassId,
                ArticleTitle   = articleTitle,
                ClassInfo      = classInfo
            };
            List <ArticleClassInfo> classPath = ArticleClass.GetArticleClassPath(articleClassId);

            ViewData["classPath"] = classPath;
            SiteUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&articleClassId={5}&newsTitle={6}",
                                                          Url.Action("List"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          sortColumn,
                                                          sortDirection,
                                                          articleClassId,
                                                          articleTitle));
            return(View(model));
        }
Пример #15
0
        // GET: Article
        public ActionResult Index()
        {
            ViewBag.ArticleCategory = GetAllCategoryForDLL().AsEnumerable();
            ArticleBll       articleBll       = new ArticleBll();
            ArticleListModel articleListModel = new ArticleListModel();
            Article          a = new Article();

            articleListModel.articleList = articleBll.GetAllArticle(a);

            return(View(articleListModel));
        }
Пример #16
0
        public ActionResult List(int?id, int?page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            var category         = _categoryService.GetCategoryById(id.Value);

            var model = new ArticleListModel();

            model.CategoryId   = id.HasValue ? id.Value : 0;
            model.CategoryName = category.Name;
            model.Description  = category.Description;
            model.Articles     = _articleService.GetAllArticle(null, model.CategoryId, 0).ToPagedList(currentPageIndex, _articleSettings.ArticlePageSize);
            return(View(model));
        }
Пример #17
0
        public ActionResult Index()
        {
            string         sql         = " Select TOP 3 * From BackImage Order By newID() ";
            List <Article> articleList = db.Article.Where(w => w.ArticleType == "1").OrderByDescending(q => q.ArticleClick).Take(10).ToList();
            //只显示公开文章
            var articleNow = db.Article.Where(w => w.ArticleType == "1").OrderByDescending(q => q.ArticleTime).Take(10).ToList();
            var model      = new ArticleListModel();

            model.BackImage  = db.Back.SqlQuery(sql).ToList();
            model.ArtcleList = articleNow;
            model.ArtcileHot = articleList;
            return(View(model));
        }
Пример #18
0
        public ActionResult Index(int?category, int page = 1, DateTime?startdate = null, DateTime?enddate = null)
        {
            IEnumerable <Article> articles = context.Articles.Include("Categories");
            int             pageSize       = 6;
            IList <Article> articlesList   = new List <Article>();

            if (category != null & category != 0)
            {
                foreach (var article in articles)
                {
                    foreach (Category c in article.Categories)
                    {
                        if (c.CategoryId == category)
                        {
                            articlesList.Add(article);
                        }
                    }
                }
            }
            else
            {
                articlesList = articles.ToList();
            }
            if (startdate != null)
            {
                articlesList = articles.Where(a => a.Date.Date >= startdate).ToList();
            }
            if (enddate != null)
            {
                articlesList = articles.Where(a => a.Date.Date <= enddate).ToList();
            }
            IEnumerable <Article> articlesPerPage = articlesList.Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = articlesList.Count()
            };
            List <Category> CategoryList = context.Categories.ToList();

            CategoryList.Insert(0, new Category {
                CategoryName = "All", CategoryId = 0
            });
            ArticleListModel articleList = new ArticleListModel
            {
                Articles   = articlesPerPage.ToList(),
                Categories = new SelectList(CategoryList, "CategoryId", "CategoryName"),
                PageInfo   = pageInfo
            };

            //var articles = context.Articles;
            return(View(articleList));
        }
Пример #19
0
        public async Task <ArticleListModel> GetListModel(ArticleQuery query)
        {
            ArticleListModel     listModel = new ArticleListModel();
            IQueryable <Article> queryable = GetIncludes(p => p.AuthorUser, x => x.ArticleTags, p => p.ArticleFavorites); //Article Yapan User ve Taglar Gelsin

            if (!string.IsNullOrWhiteSpace(query.TagId))
            {
                var isTag = await _tagServices.Get(p => p.TagId == query.TagId);

                if (isTag != null)
                {
                    queryable = queryable.Where(p => p.ArticleTags.Select(x => x.TagId).Contains(isTag.TagId));
                }
            }

            if (query.UserId > 0)
            {
                var isUser = await _userServices.Get(p => p.Id == query.UserId);

                if (isUser != null)
                {
                    //Eğer Like yaptıklarını istiyorsak...
                    if (query.OnlyLiked)
                    {
                        queryable = queryable.Where(p => p.ArticleFavorites.Any(x => x.UserId == isUser.Id));
                    }
                    else
                    {
                        queryable = queryable.Where(p => p.AuthorUserId == isUser.Id);
                    }
                }
            }


            //.Select(p => new ArticleViewModel {Id=p.Id, AuthorUser = p.AuthorUser, AuthorUserId = p.AuthorUserId, Body = p.Body, CreatedAt = p.CreatedAt, Description = p.Description, Slug = p.Slug, Title = p.Title, UpdatedAt = p.UpdatedAt, Tags = p.ArticleTags.Select(x => x.TagId).ToList() })
            var articleList = queryable.OrderByDescending(p => p.UpdatedAt).Skip(query.Offset * query.Limit).Take(query.Limit).ToList();


            await Task.Run(() => listModel.Articles = _mapper.Map <List <Article>, List <ArticleViewModel> >(articleList));

            //listModel.Articles.ForEach(p =>
            //{
            //    p.Tags = articleList.FirstOrDefault(x => x.Id == p.Id).ArticleTags.Select(x => x.TagId).ToList();
            //});
            listModel.TotalCount = queryable.Count();

            return(listModel);
        }
Пример #20
0
        public ActionResult List(string articleTitle, string Keyword, string sortColumn, string sortDirection, int?articleClassId1, int pageSize = 15, int pageNumber = 1)
        {
            pageSize = WorkContext.SiteConfig.pageSize;
            int articleClassId = 0;

            if (articleClassId1 == null)
            {
                articleClassId = 243;
            }
            else
            {
                articleClassId = (int)articleClassId1;
            }

            ArticleClassInfo classInfo = ArticleClass.AdminGetModelById(articleClassId);

            int userID = WorkContext.Uid;

            string condition = Article.AdminGetArticleListCondition(articleClassId, articleTitle);

            string    condition1 = @" ( " + condition + @" or [Keyword] = 4 ) " + " and [AdminID] = " + userID;
            string    sort       = Article.AdminGetArticleListSort(sortColumn, sortDirection);
            PageModel pageModel  = new PageModel(pageSize, pageNumber, Article.AdminGetArticleCount(condition1));

            ArticleListModel model = new ArticleListModel()
            {
                DataList       = Article.AdminGetArticleList(pageModel.PageSize, pageModel.PageNumber, condition1, sort),
                PageModel      = pageModel,
                SortColumn     = sortColumn,
                SortDirection  = sortDirection,
                ArticleClassID = articleClassId,
                ArticleTitle   = articleTitle,
                ClassInfo      = classInfo
            };

            SiteUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&articleClassId={5}&newsTitle={6}",
                                                          Url.Action("List"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          sortColumn,
                                                          sortDirection,
                                                          articleClassId,
                                                          articleTitle));
            List <ArticleClassInfo> classPath = ArticleClass.GetArticleClassPath(articleClassId);

            ViewData["classPath"] = classPath;
            return(View(model));
        }
Пример #21
0
        public ActionResult List(string titlePart = null, string type = null)
        {
            List <Article> articles = _articleSrv.GetArticles(titlePart, type);

            ArticleListModel model = new ArticleListModel();

            model.Articles    = _mapper.Map <List <ArticleDetailsModel> >(articles);
            model.IsMod       = _user?.Type?.Code.In(UserType.UserTypeCodes.ADM.ToString(), UserType.UserTypeCodes.MOD.ToString());
            model.ArticleType = type;

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ArticlesWithDetails", model));
            }

            return(View(model));
        }
        public async Task <IActionResult> Search([FromQuery] string title)
        {
            var articles = await _articleRepository.Query().Where(a => a.Title.Contains(title)).Take(20).AsNoTracking().ToListAsync();

            var result = new ArticleListModel
            {
                Articles = articles.Select(a => new ArticleModel
                {
                    Id        = a.Id,
                    Title     = a.Title,
                    Content   = a.Content,
                    Date      = a.Date,
                    Published = a.Published
                })
            };

            return(Ok(result));
        }
Пример #23
0
        public async Task <IActionResult> Search([FromQuery] string title)
        {
            var articles = await _articleRepository.Search(title);

            var result = new ArticleListModel
            {
                Articles = articles.Select(a => new ArticleModel
                {
                    Id        = a.Id,
                    Title     = a.Title,
                    Content   = a.Content,
                    Date      = a.Date,
                    Published = a.Published
                })
            };

            return(Ok(result));
        }
Пример #24
0
        public ActionResult ArticleContent(int articleId)
        {
            //阅读量
            var articleCount = db.Article.Where(q => q.ArticleId == articleId).FirstOrDefault();

            articleCount.ArticleClick += 1;
            db.SaveChanges();

            //文章内容
            Article articleContent = db.Article.Where(q => q.ArticleId == articleId).FirstOrDefault();
            //top10热门文章
            List <Article> articleList = db.Article.Where(w => w.ArticleType == "1").OrderByDescending(q => q.ArticleClick).Take(10).ToList();

            var model = new ArticleListModel();

            model.ArtcileHot    = articleList;
            model.ArtcleContent = articleContent;
            return(View(model));
        }
Пример #25
0
        public async Task <IActionResult> Search([FromQuery] string title)
        {
            var titleLikeClause = "%" + title + "%";
            var articles        = await _articleRepository.Query().Where(a => EF.Functions.Like(a.Title, titleLikeClause) || EF.Functions.Like(a.Content, titleLikeClause)).Take(20).ToListAsync();

            var result = new ArticleListModel
            {
                Articles = articles.Select(a => new ArticleModel
                {
                    Id        = a.Id,
                    Title     = a.Title,
                    Content   = a.Content,
                    Date      = a.Date,
                    Published = a.Published
                })
            };

            return(Ok(result));
        }
Пример #26
0
        public ActionResult List(string keyWord = "", int?pageIndex = 1, int?categoryId = 0)
        {
            commonInfo.WirteLog("List开始时间");
            //  var keyWord = Request.Form["title"];
            categoryId = categoryId == null ? 0 : categoryId;   //书的目录id
            if (categoryId != 0)
            {
                s_categoryId = Convert.ToInt32(categoryId);
            }
            if (categoryId == 0 && s_categoryId != 0 && !string.IsNullOrEmpty(keyWord))
            {
                categoryId = s_categoryId;
            }
            s_categoryId = Convert.ToInt32(categoryId);
            pageIndex    = (pageIndex == 0 || pageIndex == null) ? 1 : pageIndex;
            BookQueryData query = new BookQueryData();

            query.CategoryIdOne  = (TypeEnum)0;
            query.KeyWordOneSimp = keyWord;
            query.KeyWordOneOrig = FontTypeConvert.VBConvertOrig(keyWord);
            commonInfo.WirteLog("List简繁转换");
            int            count    = 0;
            List <TB_Book> bookList = _bookService.GetBookListByQueryData(query, out count, Convert.ToInt32(pageIndex), pageSize, Convert.ToInt32(categoryId)).ToList();

            commonInfo.WirteLog("List书籍List");
            List <BookViewModel> models = GetQueryList(bookList);

            commonInfo.WirteLog("List列表分页");
            s_keyWord    = keyWord;
            s_categoryId = 0;
            ArticleListModel articleModel = new ArticleListModel();

            articleModel.CategoryId       = Convert.ToInt32(categoryId);
            articleModel.KeyFan           = FontTypeConvert.VBConvertOrig(keyWord);
            articleModel.KeyJian          = FontTypeConvert.VBConvertSimp(keyWord);
            articleModel.KeyWord          = keyWord;
            articleModel.BooViewModelList = models;
            articleModel.Count            = count;
            articleModel.PageSize         = pageSize;
            articleModel.PageTotalCount   = count % pageSize == 0 ? count / pageSize : (int)Math.Ceiling((double)(count / pageSize)) + 1;
            articleModel.CurrentPageIndex = pageIndex > articleModel.PageTotalCount ? 1 : Convert.ToInt32(pageIndex);
            return(View("List", articleModel));
        }
Пример #27
0
        public async Task <IActionResult> Search([FromQuery] string title)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                return(BadRequest(ApiResponse.BadRequest("Argument title is null")));
            }

            var model = await _articleRepository.Query()
                        .Where(a => a.Title.Contains(title) || a.Content.Contains(title))
                        .OrderByDescending(a => a.Date)
                        .Take(20)
                        .ToArrayAsync();

            var result = new ArticleListModel
            {
                Articles = model.Select(a => a.AsDto())
            };

            return(Ok(ApiResponse.Ok(result)));
        }
Пример #28
0
        public ActionResult Index(bool isUserNews = false, bool isInterestingNews = false)
        {
            //System.Text.RegularExpressions.Regex.Replace()
            var     list        = new PagedList <DemoArticle>();
            int     userId      = 0;
            AppUser currentUser = userRepo.GetById(User.Identity.GetUserId <int>());

            if (!isInterestingNews)
            {
                if (isUserNews)
                {
                    userId = currentUser.Id;
                }
                list = repo.GetDemoList(new ArticleCriteria()
                {
                    StartFrom = 0, UserId = userId, Count = NumberOfItemsOnPage, LastId = 0
                });
            }
            else
            {
                list = repo.GetArticleByTags(currentUser.Tags, new ArticleCriteria()
                {
                    StartFrom = 0, UserId = 0, Count = NumberOfItemsOnPage, LastId = 0
                });
            }
            var model = new ArticleListModel();

            model.UsierId = userId;
            model.Type    = "default";
            if (isInterestingNews)
            {
                model.Type = "tags";
            }
            else if (isUserNews)
            {
                model.Type = "my";
            }
            model.ArticleList = list;
            model.TagList     = tagRepo.GetAllTags().ToList();
            return(View(model));
        }
Пример #29
0
        public ActionResult Index()
        {
            ArticleListModel model = new ArticleListModel();

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                // model.ProjectList = db.Articles.Include("ArticleStatus").OrderBy(a => a.UpdateDate).Take(5).ToList();
                //Projects needing funding
                model.ArticleList = db.Articles.Include("ArticleStatus").ToList();
                //model.ProjectList = db.Articles.Include("ArticleStatus").Where(a => a.ArticleStatus.Any(arts => arts.StatusId == 4)).Take(5).ToList();
                ////Projects recently updated
                //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 2).OrderBy(a => a.UpdateDate).Take(5).ToList());
                ////Post recently added
                //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 1).OrderBy(a => a.CreatedDate).Take(5).ToList());
                ////News recently added
                //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).Take(5).ToList());
                ////model.ProjectList = db.Articles.Include()
                ////var articles = db.Articles.Where(a => a.ArticleTypeId == 2 && a.ArticleStatus.Any(ar => ar.StatusId==3));
            }

            return(View(model));
        }
Пример #30
0
        // GET: Articles
        public ActionResult Index(int page = 1)
        {
            int pageSize = 20;
            IEnumerable <Article> articles        = db.Articles.Include("Categories");
            IEnumerable <Article> articlesPerPage = articles.Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = articles.Count()
            };
            List <Category> CategoryList = db.Categories.ToList();

            CategoryList.Insert(0, new Category {
                CategoryName = "All", CategoryId = 0
            });
            ArticleListModel articleList = new ArticleListModel
            {
                Articles   = articlesPerPage.ToList(),
                Categories = new SelectList(CategoryList, "CategoryId", "CategoryName"),
                PageInfo   = pageInfo
            };

            return(View(articleList));
        }
Пример #31
0
        public ActionResult List()
        {
            var model = new ArticleListModel();

            return View(model);
        }
Пример #32
0
        public ActionResult List(GridCommand command, ArticleListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
                return AccessDeniedView();

            var articles = _articleService.GetAllArticles(model.SearchArticleName, command.Page - 1, command.PageSize, true);
            var gridModel = new GridModel<ArticleModel>
            {
                Data = articles.Select(x =>
                {
                    var m = x.ToModel();
                    if (x.StartDateUtc.HasValue)
                        m.StartDate = _dateTimeHelper.ConvertToUserTime(x.StartDateUtc.Value, DateTimeKind.Utc);
                    if (x.EndDateUtc.HasValue)
                        m.EndDate = _dateTimeHelper.ConvertToUserTime(x.EndDateUtc.Value, DateTimeKind.Utc);
                    m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc);
                    return m;
                }),
                Total = articles.TotalCount
            };
            return new JsonResult
            {
                Data = gridModel
            };
        }