public async Task <ActionResult> SelectTree(string tabId, int parentId, int id, bool?boundToExternal) { var result = ArticleService.InitTree(parentId, false, boundToExternal); var model = ArticleListViewModel.Create(result, parentId, tabId, false, true, new[] { id }); return(await JsonHtml("Tree", model)); }
public async Task <ActionResult> MultipleSelectTree(string tabId, int parentId, [FromBody] SelectedItemsViewModel selModel, bool?boundToExternal) { var result = ArticleService.InitTree(parentId, true, boundToExternal); var model = ArticleListViewModel.Create(result, parentId, tabId, true, true, selModel.Ids); return(await JsonHtml("Tree", model)); }
public async Task <ActionResult> Select(string tabId, int parentId, int id, bool?boundToExternal) { var articleList = ArticleService.InitList(parentId, boundToExternal); var model = ArticleListViewModel.Create(articleList, parentId, tabId, false, true, id); return(await JsonHtml("Index", model)); }
public ActionResult RelatedArticles(string id, int page = 1) { var relatedArticles = this.articles.GetRelatedArticles(id); var allItemsCount = relatedArticles.Count(); var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage); var itemsToSkip = (page - 1) * ItemsPerPage; var result = relatedArticles.OrderByDescending(x => x.CreatedOn) .Skip(itemsToSkip) .Take(ItemsPerPage) .To <ArticleViewModel>() .ToList(); if (result == null) { return(this.RedirectToAction("NoArticlesFound")); } var viewModel = new ArticleListViewModel() { CurrentPage = page, TotalPages = totalPages, Articles = result }; return(this.View("RelatedArticles", viewModel)); }
public IActionResult Index() { var listArticle = new ArticleListViewModel(); listArticle.Articles = _articleRepository.GetAllArticles().Take(4); return(View(listArticle)); }
public ActionResult RelatedArticles(string id, int page = 1) { var relatedArticles = this.articles.GetRelatedArticles(id); var allItemsCount = relatedArticles.Count(); var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage); var itemsToSkip = (page - 1) * ItemsPerPage; var result = relatedArticles.OrderByDescending(x => x.CreatedOn) .Skip(itemsToSkip) .Take(ItemsPerPage) .To<ArticleViewModel>() .ToList(); if (result == null) { return this.RedirectToAction("NoArticlesFound"); } var viewModel = new ArticleListViewModel() { CurrentPage = page, TotalPages = totalPages, Articles = result }; return this.View("RelatedArticles", viewModel); }
public ViewResult Watch(int id) { ArticleListViewModel model = new ArticleListViewModel { Articles = repository.Articles }; string title = ""; string text = ""; int note = 0; string teacher = ""; string student = ""; foreach (var t in model.Articles) { if (t.Id == id) { title = t.Title; text = t.Text; note = t.Note; teacher = t.Teacher; student = t.Student; } } Article modelone = new Article { Id = id, Title = title, Text = text, Note = note, Teacher = teacher, Student = student }; return(View(modelone)); }
public async Task <IActionResult> ListAsync(int?page = 1, int?count = 6, int?categoryId = null) { try { (List <ArticleModel> models, long total) = await this.articleManagement.GetArticleListAsync(page.Value, count.Value, categoryId.GetValueOrDefault()); ArticleListViewModel model = new ArticleListViewModel { Articles = models, CategoryId = categoryId, Pagination = new PaginationModel { AmountPerPage = count.Value, Page = page.Value, TotalItems = total } }; List <CategoryModel> categoryList = await this.categoryManagement.GetCategoryListAsync(DataAccess.Enums.CategoryType.Article).ConfigureAwait(false); ViewData["Categories"] = new SelectList(categoryList, nameof(CategoryModel.Id), nameof(CategoryModel.Name)); return(View("List", model)); } catch (Exception ex) { return(View("ErrorAdmin", new ErrorViewModel { Message = ex.Message })); } }
public ActionResult List() { var currentContextItem = Sitecore.Context.Item; List <Sitecore.Data.Items.Item> articleItems = currentContextItem.GetChildren().ToList(); List <ArticleViewModel> articleViewModelList = new List <ArticleViewModel>(); foreach (Sitecore.Data.Items.Item articleItem in articleItems) { //projectExampleLogger.Info("Title: " + articleItem.Fields["Title"].Value + ", Body: " + articleItem.Fields["Body"].Value + ",Summary: " + articleItem.Fields["Summary"].Value); ArticleViewModel articleViewModel = new ArticleViewModel() { ArticleModel = new ArticleModel() { Title = articleItem.Fields["ArticleTitle"].Value, Body = articleItem.Fields["ArticleBody"].Value, Summary = articleItem.Fields["ArticleSummary"].Value }, Url = Sitecore.Links.LinkManager.GetItemUrl(articleItem) }; articleViewModelList.Add(articleViewModel); } var viewModel = new ArticleListViewModel { ArticleList = articleViewModelList }; return(View(viewModel)); }
public IActionResult List() { // if (_file.Exists("tp_mspr.db")) // { // _file.Delete("tp_mspr.db"); // } _context.Database.EnsureCreated(); _context.Articles.Add(new Article { Libelle = "PC ASUS", SKU = "PC01", DateSortie = DateTime.Now, PrixInitial = 590.90F, Poids = 2.8F }); _context.Articles.Add(new Article { Libelle = "PC LENOVO", SKU = "PC02", DateSortie = DateTime.Now, PrixInitial = 699.90F, Poids = 3.8F }); _context.SaveChanges(); var articleListViewModel = new ArticleListViewModel(); articleListViewModel.Articles = _articleRepository.GetAllArticles(); return(View(articleListViewModel)); }
public async Task <IActionResult> Index(string typeSlug = null) { ArticleType type = null; if (typeSlug.HasValue()) { type = await _dbContext.ArticleTypes.FirstOrDefaultAsync(x => x.Slug == typeSlug); } var articles = await _dbContext.Articles .Include(x => x.ArticleType) .Where(x => x.DeletedOn == null && (type == null || x.ArticleTypeId == type.Id)) .ProjectTo <ArticleModel>() .ToListAsync(); var model = new ArticleListViewModel { Articles = articles }; if (type != null) { model.Type = Mapper.Map <ArticleTypeModel>(type); } return(View(model)); }
public ActionResult Index(string tabId, int parentId, bool?boundToExternal) { var articleList = ArticleService.InitList(parentId, boundToExternal); var model = ArticleListViewModel.Create(articleList, parentId, tabId); return(JsonHtml("Index", model)); }
public IActionResult Index() { ArticleListViewModel viewModel = new ArticleListViewModel(); viewModel.AllArticles = _articleLogic.GetAll(); return(View(viewModel)); }
public ActionResult MultipleSelectTree(string tabId, int parentId, int[] IDs, bool?boundToExternal) { var result = ArticleService.InitTree(parentId, true, boundToExternal); var model = ArticleListViewModel.Create(result, parentId, tabId, true, true, IDs); return(JsonHtml("Tree", model)); }
public ActionResult Index() { ArticleListViewModel alvm = new ArticleListViewModel(); alvm.SideBarData = new SideBarViewModel(); alvm.SideBarData.CurrentIndex = 1; ArticleBusinessLayer articleBusinessLayer = new ArticleBusinessLayer(); /* Code by Dwayne 2015-12-3 17:02:50 */ const int numPerPage = 5; int pageNum = Int32.Parse(RouteData.Values["id"].ToString()) - 1; List <Article> articleList = articleBusinessLayer.GetArticleList(); alvm.ArticleList = articleList.Skip(pageNum * numPerPage).Take(numPerPage).ToList(); alvm.PageNum = pageNum; alvm.ArticleNum = alvm.ArticleList.Count; alvm.TotalNum = articleList.Count; if (HttpContext.Session["User"] != null && Session["User"].ToString() != "") { alvm.NavStatusData = new NavStatusViewModel(); alvm.NavStatusData.LeftLink = "/User/Profile/" + HttpContext.Session["User"].ToString(); alvm.NavStatusData.LeftText = Session["User"].ToString(); alvm.NavStatusData.RightLink = "/User/Logout"; alvm.NavStatusData.RightText = "Log out"; } return(View("", alvm)); }
public ActionResult Index(string searchString, string category = "All Categories") { ArticleListViewModel model = new ArticleListViewModel(); model.Articles = _unitOfWork.Articles.GetAll(); model.SelectedCategory = category; model.AllCategories = _unitOfWork.Articles.GetAllCategories(); if (!category.Contains("All Categories")) { model.Articles = model.Articles.Where(a => a.Category.Contains(category)); } if (!String.IsNullOrEmpty(searchString)) { model.Articles = model.Articles.Where(a => a.Title.ToLower().Contains(searchString.ToLower())); } if (User.IsInRole("Admin")) { return(View("IndexForAdmin", model)); } return(View("Index", model)); }
public BaseViewModel CreateViewModel(IPublishedContent content) { var rootNodes = _nodeHelper.Umbraco.TypedContentAtRoot(); var articlesRootNode = rootNodes.First(x => x.DocumentTypeAlias == "articlesRoot"); var allArticles = articlesRootNode.Children.SelectMany(x => x.Children).ToList(); var viewModel = new ArticleListViewModel { Articles = new List <ArticleCardViewModel>(), Title = content.GetPropertyValue <string>("header") }; var articlesToDisplay = allArticles.OrderByDescending(x => x.CreateDate).Take(9); articlesToDisplay.ForEach(articleModel => { viewModel.Articles.Add(new ArticleCardViewModel { Title = articleModel.GetPropertyValue <string>("title"), ShortDescription = articleModel.GetPropertyValue <string>("shortDescription"), Tags = articleModel.GetPropertyValue <string>("tags").Split(','), CardImage = articleModel.GetImage("cardImage", _nodeHelper).WithQuality(70).WithHeight(160).WithWidth(330).WithCrop(), Url = articleModel.Url }); }); return(viewModel); }
public async Task <ActionResult> ArchiveIndex(string tabId, int parentId, bool?boundToExternal) { var articleList = ArticleService.InitArchiveList(parentId); var model = ArticleListViewModel.Create(articleList, parentId, tabId); model.ShowArchive = true; return(await JsonHtml("Index", model)); }
public IActionResult search(string q) { var aricleListViewModel = new ArticleListViewModel() { Articles = _articleServices.GetSearchResult(q) }; return(View(aricleListViewModel)); }
public IActionResult Articles() { var model = new ArticleListViewModel { Articles = _articleService.GetArticleAndCategory().Data }; return(View(model)); }
public override ActionResult Index(ContentModel model) { var viewModel = new ArticleListViewModel(model.Content) { Articles = _articleListService.Get() }; return(CurrentTemplate(viewModel)); }
public IActionResult AddFoodlog() { var viewModel = new ArticleListViewModel { AllArticles = _articleLogic.GetAll() }; return(View(viewModel)); }
/// <summary> /// /// List /// /// Auth = False /// /// </summary> public IActionResult List() { var viewModel = new ArticleListViewModel { AllArticles = _articleLogic.GetAll(), AllDishes = _dishLogic.GetAll() }; return(View(viewModel)); }
public ArticlesList() { InitializeComponent(); BindingContext = new ArticleListViewModel(Navigation); ArticleList.ItemTapped += (sender, args) => { Article article = (Article)args.Item; Navigation.PushAsync(new ArticleDetail(article)); }; }
// GET: Article public ActionResult Index() { //return View(RSS.Read("http://www.alexandracooks.com/feed/")); var articles = Using <GetArticleList>() .Execute(); var model = new ArticleListViewModel(articles); return(View(model)); }
public ActionResult SearchArticle(string searchString = null, int pageNumber = 1) { var take = 3; var articles = new List <Article>(); var articleListVm = new List <ArticleListViewModel>(); if (!string.IsNullOrEmpty(searchString)) { articles = _repo.GetArticles().Where(a => a.Title.ToLower().Trim().Contains(searchString.ToLower().Trim()) || a.ShortDescription.ToLower() .Trim().Contains(searchString.ToLower().Trim())) .ToList(); } else { articles = _repo.GetArticles(); } int pageCount = articles.Count / take + 1; ViewBag.SearchString = searchString; ViewBag.PageCount = pageCount; ViewBag.CurrentPage = pageNumber; var skip = (pageNumber - 1) * take; articles = articles.Skip(skip).Take(take).ToList(); foreach (var item in articles) { var vm = new ArticleListViewModel(item); var commentCount = _repo.GetArticleComments(item.Id).Count; vm.CommentCount = commentCount; articleListVm.Add(vm); } #region BreadCrumb var breadCrumbVm = new List <BreadCrumbViewModel>(); breadCrumbVm.Add(new BreadCrumbViewModel() { Title = "بلاگ", Href = "/Blog" }); if (!string.IsNullOrEmpty(searchString)) { breadCrumbVm.Add(new BreadCrumbViewModel() { Title = $"جستجو : {searchString}", Href = "#" }); } ViewBag.BreadCrumb = breadCrumbVm; #endregion return(View(articleListVm)); }
public MainPage() { InitializeComponent(); BindingContext = new ArticleListViewModel(Navigation); ArticleList.ItemTapped += (sender, args) => { Article article = (Article)args.Item; Navigation.PushAsync(new ArticleDetail(article)); }; ButtonCreateView.Clicked += (sender, args) => { }; }
public IActionResult All(int id = 1) { const int itemsPerPage = 12; var viewModel = new ArticleListViewModel() { ItemsPerPage = itemsPerPage, PageNumber = id, Articles = this.articlesService.GetAll <ArticleViewModel>(id, 12), ItemsCount = this.articlesService.GetCount(), }; return(this.View(viewModel)); }
public ActionResult Index(int id, int pageNumber = 1, string searchString = null) { var take = 3; var articleListVm = new List <ArticleListViewModel>(); var category = _repo.GetArticleCategory(id); var articles = _repo.GetArticlesByCategoryId(id); if (!string.IsNullOrEmpty(searchString)) { articles = articles.Where(a => a.Title.ToLower().Trim().Contains(searchString.ToLower().Trim()) || a.ShortDescription.ToLower().Trim().Contains(searchString.ToLower().Trim())) .ToList(); } int pageCount = articles.Count / take + 1; ViewBag.PageCount = pageCount; ViewBag.CategoryId = category.Id; ViewBag.CategoryName = category.Title; ViewBag.CurrentPage = pageNumber; var skip = (pageNumber - 1) * take; articles = articles.Skip(skip).Take(take).ToList(); foreach (var item in articles) { var vm = new ArticleListViewModel(item); var commentCount = _repo.GetArticleComments(item.Id).Count; vm.CommentCount = commentCount; articleListVm.Add(vm); } #region BreadCrumb var breadCrumbVm = new List <BreadCrumbViewModel>(); breadCrumbVm.Add(new BreadCrumbViewModel() { Title = "بلاگ", Href = "/Blog" }); breadCrumbVm.Add(new BreadCrumbViewModel() { Title = category.Title, Href = $"/Blog/{category.Id}/{category.Title.Replace(" ", "-")}" }); if (!string.IsNullOrEmpty(searchString)) { breadCrumbVm.Add(new BreadCrumbViewModel() { Title = $"جستجو : {searchString}", Href = "#" }); } ViewBag.BreadCrumb = breadCrumbVm; #endregion return(View(articleListVm)); }
public ArticleListViewModel UpdateArticleListModel(int currentPage, int itemsPerPage) { ArticleListViewModel modelOutput = new ArticleListViewModel(); List <Article> articleList = dbHelper.GetAllArticles(); articleList.OrderBy(a => a.Name); JasperPaging <Article> paging = new JasperPaging <Article>(articleList, currentPage, itemsPerPage); modelOutput.CurrentPage = paging.CurrentPageNumber; modelOutput.TotalNumberOfPages = paging.NumberOfPagesNeeded; modelOutput.Articles = paging.GetCurrentPageItems(); return(modelOutput); }
public IActionResult Category(int categoryId, string categoryName, int id = 1) { const int itemsPerPage = 12; var viewModel = new ArticleListViewModel() { ItemsPerPage = itemsPerPage, PageNumber = id, Articles = this.articlesService.GetByCategory <ArticleViewModel>(1, 12, categoryId), ItemsCount = this.articlesService.GetCount(), CategoryName = categoryName, }; return(this.View(viewModel)); }
public ActionResult Index(int id = 1) { var page = id; var allItemsCount = this.articles.Count(); var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage); var itemsToSkip = (page - 1) * ItemsPerPage; var allArticles = this.articles .GetAll() .OrderByDescending(x => x.CreatedOn) .Skip(itemsToSkip) .Take(ItemsPerPage) .To<ArticleViewModel>() .ToList(); var viewModel = new ArticleListViewModel() { CurrentPage = page, TotalPages = totalPages, Articles = allArticles }; return this.View(viewModel); }