public IActionResult Search(string tagName) { if (String.IsNullOrEmpty(tagName)) { return(View(new BlogSearchViewModel(GetModelData()))); } List <BlogItem> blogs = _blogProvider.Search(tagName); if (blogs.Count == 0) { ModelState.AddModelError(String.Empty, Languages.LanguageStrings.NoBlogsFoundMatchingTags); } if (ModelState.IsValid) { BlogPostsViewModel model = GetBlogPostViewModel(blogs); model.Breadcrumbs.RemoveAt(2); model.Breadcrumbs.Add(new BreadcrumbItem(Languages.LanguageStrings.Search, $"/{Name}/{nameof(Search)}/", false)); model.Breadcrumbs.Add(new BreadcrumbItem(tagName, $"/{Name}/{nameof(Search)}/{tagName}/", false)); return(View(nameof(Index), model)); } return(View(new BlogSearchViewModel(GetModelData()))); }
public ActionResult Delete(int[] ids) { if (ids == null || !ids.Any()) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = new BlogPostsViewModel(); model.BlogPosts = new List <BlogPostViewModel>(); foreach (int id in ids) { BlogPost blogPost = blogPostService.Find(id); if (blogPost == null) { continue; } model.BlogPosts.Add(new BlogPostViewModel { Id = blogPost.Id, Title = blogPost.Title, }); } return(View(model)); }
private void DeleteClicked(object sender, EventArgs e) { var mi = ((MenuItem)sender); var favouriteBlogPost = (FavouriteBlogPost)mi.CommandParameter; App.database.DeleteFavouriteBlogPost(favouriteBlogPost); DisplayAlert("Successful", "Blog Post was successfully removed from your favourite list", "OK"); BindingContext = new BlogPostsViewModel(true); }
public IActionResult Index(int pageNumber = 1) { var model = new BlogPostsViewModel(_blogPostsConfig) { PageOfBlogPosts = _blogPostsConfig.GetPage(pageNumber), CurrentPageNumber = pageNumber }; return(View(model)); }
public IActionResult Index(string category) { var model = new BlogPostsViewModel(_blogPostsConfig) { PageOfBlogPosts = _blogPostsConfig.GetBlogPostsWithCategory(category), Category = category }; return(View(model)); }
public ActionResult Index() { var blogPost = blogPostService.FindAll().ToList(); var model = new BlogPostsViewModel { BlogPosts = Mapper.Map <List <BlogPostViewModel> >(blogPost) }; return(View(model)); }
public BlogPostsViewModel BlogPagedPublishedList(int page, int pageSize, bool isPublished) { var blogData = _repository.GetAll().Where(i => i.IsPublished == isPublished).Skip((page - 1) * pageSize).Take(pageSize); var blogList = new BlogPostsViewModel(); blogList.Posts = blogData.ToList(); return(blogList); }
public ActionResult Index() { var model = new BlogPostsViewModel { TopBlogPosts = Enumerable.Empty <BlogPost>(), BlogPosts = repository.GetBlogPosts() }; return(View("Index", model)); }
public BlogPostsPage() { InitializeComponent(); try { _viewModel = new BlogPostsViewModel(new KenticoCloudService()); RefreshBlogPosts(0); } catch (Exception ex) { HandleException(ex); } }
public IActionResult Index(string tag) { if (string.IsNullOrEmpty(tag)) { return(Redirect("~/tags")); } var model = new BlogPostsViewModel(_blogPostsConfig) { PageOfBlogPosts = _blogPostsConfig.GetBlogPostsWithTag(tag), Tag = tag }; return(View(model)); }
public IActionResult Index(int page) { if (page < 1) { page = 1; } BlogPostsDb db = new(_connectionString); BlogPostsViewModel vm = new BlogPostsViewModel { blogPosts = db.GetAllBlogPosts(page), currentPage = page, totalPages = db.GetTotalPages() }; return(View(vm)); }
public IActionResult Search(BlogSearchViewModel model) { List <BlogItem> blogs = _blogProvider.Search(model.TagName); if (blogs.Count == 0) { ModelState.AddModelError(String.Empty, Languages.LanguageStrings.NoBlogsFoundMatchingTags); } if (ModelState.IsValid) { BlogPostsViewModel searchModel = GetBlogPostViewModel(blogs); searchModel.Breadcrumbs.Add(new BreadcrumbItem(model.TagName, $"/{Name}/{nameof(Search)}/{model.TagName}/", false)); return(View(nameof(Index), searchModel)); } return(View(new BlogSearchViewModel(GetModelData()))); }
public IActionResult Index(string searchText) { List <BlogPost> result = new List <BlogPost>(); if (!string.IsNullOrEmpty(searchText) && searchText.Length > 2) { foreach (var post in _blogPostsConfig.Blogs) { // Add if a category of the post matches the search text if (post.Categories.Any(c => c.Equals(searchText, StringComparison.OrdinalIgnoreCase))) { result.Add(post); continue; } // Add if a tag of the post matches the search text if (post.Tags.Any(c => c.Equals(searchText, StringComparison.OrdinalIgnoreCase))) { result.Add(post); continue; } if (string.IsNullOrEmpty(post.Content)) { post.Content = BlogPostContentReader.GetContent(post, _cache, _logger); } if (post.Content.Contains(searchText, StringComparison.OrdinalIgnoreCase)) { result.Add(post); } } } var model = new BlogPostsViewModel(_blogPostsConfig) { SearchText = searchText, PageOfBlogPosts = result }; return(View(model)); }
public ActionResult Delete(int[] ids) { if (ids == null || !ids.Any()) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var model = new BlogPostsViewModel(); model.BlogPosts = new List<BlogPostViewModel>(); foreach (int id in ids) { BlogPost blogPost = blogPostService.Find(id); if (blogPost == null) continue; model.BlogPosts.Add(new BlogPostViewModel { Id = blogPost.Id, Title = blogPost.Title, }); } return View(model); }
public FavouriteBlogPosts() { InitializeComponent(); BindingContext = new BlogPostsViewModel(true); }
public BlogPosts() { InitializeComponent(); BindingContext = new BlogPostsViewModel(this.Navigation); }
public IActionResult Index() { BlogPostsViewModel model = GetBlogPostViewModel(_blogProvider.GetRecentPosts(10, true)); return(View(model)); }
public ActionResult Index() { var blogPost = blogPostService.FindAll().ToList(); var model = new BlogPostsViewModel { BlogPosts = Mapper.Map<List<BlogPostViewModel>>(blogPost) }; return View(model); }
protected override void OnAppearing() { base.OnAppearing(); ((App)App.Current).ResumeAtBlogWebsiteId = -1; BindingContext = new BlogPostsViewModel(true); }