public Task <IEnumerable <DashboardBlogDto> > GetBlogAsync(BlogQuery query, CancellationToken token) { //var blogName = "English"; //if (country == Country.Israel) //{ // blogName = "Hebrew"; //} using var reader = XmlReader.Create("https://www.blog.spitball.co/blog-feed.xml"); var formatter = new Rss20FeedFormatter(); formatter.ReadFrom(reader); var items = formatter.Feed.Items; token.ThrowIfCancellationRequested(); var result = items .Where(w => w.Categories.Any(a => a.Name == query.Category) && w.Categories.Any(a => a.Name == query.BlogName)) .Select(s => new DashboardBlogDto { Image = s.Links.Where(w => w.RelationshipType == "enclosure").Select(s2 => s2.Uri).First() .ChangeToHttps(), Url = s.Links.Where(w => w.RelationshipType == "alternate").Select(s2 => s2.Uri).First(), Title = s.Title.Text, Uploader = s.ElementExtensions .ReadElementExtensions <string>("creator", "http://purl.org/dc/elements/1.1/").FirstOrDefault(), Create = s.PublishDate }).OrderByDescending(o => o.Create).Take(query.Amount); return(Task.FromResult(result)); }
/// <summary> /// returns all blog categories /// </summary> /// <returns></returns> public ActionResult Categories() { var query = new BlogQuery(); var blogCategories = _blogQueryService.GetAllBlogCategories(query); return(View("Categories", blogCategories)); }
public ActionResult Post(int year, int month, int day, string urlSlug) { var query = new BlogQuery(year, month, day, urlSlug); var blogPost = _blogQueryService.GetBlogPost(query); return(View("Post", blogPost)); }
public IActionResult GetBlogsPage(BlogQuery blogQuery) { PaggingResult <Blog> blogPage = unitOfWork.Blogs.GetBlogsPage(blogQuery); return(Ok(blogPage)); }
/// <summary> /// 取得所有 Blog /// </summary> /// <param name="blogQuery">查詢條件</param> /// <returns></returns> public async Task <IEnumerable <Blog> > GetAsync(BlogQuery blogQuery) { // 資料庫實作 using (IDbConnection conn = this._databaseHelper.GetConnection()) { string sql = @" SELECT BlogId, Url FROM Blog WHERE BlogId = @BlogId OR Url = @Url"; var Blogs = await conn.QueryAsync <Blog>( sql, new { blogQuery.BlogId, blogQuery.Url }); return(Blogs); } }
public PaggingResult <Blog> GetBlogsPage(BlogQuery query) { var blogsTable = context.Blogs .AsNoTracking() .Where(b => b.IsPublished == query.OnlyPublished); // Apply Ordering blogsTable = blogsTable.OrderByDescending(b => b.PublishedDate); // Convert BlogTable to Blog var blogs = mapper.Map <IEnumerable <Blog> >(blogsTable); // Tag Filter if (query.Tags != null && query.Tags.Any()) { blogs = blogs.Where( b => b.Tags.Any(s => query.Tags .Split(',', StringSplitOptions.RemoveEmptyEntries) .Contains(s, StringComparer.OrdinalIgnoreCase))); } var totalItems = blogs.Count(); // Apply Paging var blogsAfterPagging = blogs.ApplayPaging(query); var paggingResult = new PaggingResult <Blog> { CurrentPage = query.Page, PageSize = query.PageSize, TotalItems = totalItems, TResult = blogsAfterPagging }; return(paggingResult); }
public ActionResult Index() { var query = new BlogQuery(); var blogPost = _blogQueryService.GetAllBlogPosts(ref query); return(View("Index", blogPost)); }
public ActionResult Categories(string keyword) { var query = new BlogQuery(keyword); var categories = _blogQueryService.GetAllBlogCategories(query); return(View("Categories", categories)); }
/// <summary> /// returns all blog tags /// </summary> /// <returns></returns> public ActionResult Tags() { var query = new BlogQuery(); var blogTags = _blogQueryService.GetAllBlogTags(query); return(View("Tags", blogTags)); }
public async Task ExecuteAsync() { var query = new BlogQuery(_dbFactory); var result = await query.ExecuteAsync(); Assert.AreEqual(_defaultData.Count, result.Count()); }
public ActionResult Tags(string keyword) { var query = new BlogQuery(keyword); var tags = _blogQueryService.GetAllBlogTags(query); return(View("Tags", tags)); }
public ActionResult List() { var query = new BlogQuery(); var posts = _blogQueryService.GetAllBlogPosts(ref query); return(View("List", posts)); }
private void FillTags(IBlogPostCommand command) { var query = new BlogQuery(); var tags = _blogQueryService.GetAllBlogTags(query); command.BlogTags = tags.ToCommand(); }
private void FillCategories(IBlogPostCommand command) { var query = new BlogQuery(); var categories = _blogQueryService.GetAllBlogCategories(query); ViewBag["BlogCategories"] = categories.ToCommand(); }
public void Execute() { var query = new BlogQuery(_dbFactory); var result = query.Execute(); Assert.AreEqual(_defaultData.Count, result.Count()); }
public async Task GetTotalRowCountAsync() { var query = new BlogQuery(_dbFactory); var result = await query.GetTotalRowCountAsync(); Assert.AreEqual(_defaultData.Count, result); }
public async Task <BlogDtoPaged> GetAllBlogsPaged(BlogQuery query) { var result = await _blogRepository.GetAllPagedAsync( query.Page, query.Size, query.Filter, query.Order, b => b.Title.Contains(query.SearchQuery) ); var entities = result.Entities.AsQueryable(); result.Entities = _blogRepository.Sort(entities, query.Filter, query.Order).ToList(); return(new BlogDtoPaged(_mapper, result, query.Page, query.Size)); }
public void Take() { const int takeNumber = 10; var query = new BlogQuery(_dbFactory); query.Take = takeNumber; var result = query.Execute(); Assert.AreEqual(takeNumber, result.Count()); var first = result.First(); Assert.AreEqual(_defaultData.First().Name, first.Name); }
public void Skip() { const int skipNumber = 10; var query = new BlogQuery(_dbFactory); query.Skip = skipNumber; var result = query.Execute(); Assert.AreEqual(_defaultData.Count - 10, result.Count()); var first = result.First(); Assert.AreEqual(skipNumber + 1, first.Id); }
public void AddSortCriteria_propertyName() { var query = new BlogQuery(_dbFactory); query.AddSortCriteria("name"); var result1 = query.Execute(); var first = result1.First(); Assert.AreEqual(_defaultData.First().Name, first.Name); query.ClearSortCriteria(); query.AddSortCriteria("name", SortDirection.Descending); var result2 = query.Execute(); var last = result2.First(); Assert.AreEqual(_defaultData.Last().Name, last.Name); }
public async Task <IActionResult> Post([FromBody] GraphQlQuery query) { IObjectGraphType currentObjectGraphType = null; switch (query.OperationName) { case "GetBlogData": currentObjectGraphType = new BlogQuery(blogService); break; case "GetAuthors": currentObjectGraphType = new AuthorsQuery(blogService); break; default: currentObjectGraphType = new BlogQuery(blogService); break; } var schema = new Schema { Query = currentObjectGraphType }; var result = await new DocumentExecuter().ExecuteAsync(x => { x.Schema = schema; x.Query = query.Query; x.Inputs = query.Variables; }); if (result.Errors?.Count > 0) { return(BadRequest()); } return(Ok(result)); }
public async Task <IEnumerable <DashboardBlogDto> > GetMarketingAsync( [ProfileModelBinder(ProfileServiceQuery.Country)] UserProfile profile, CancellationToken token) { return(await _blogProvider.GetBlogAsync(BlogQuery.Marketing(profile.Country), token)); }
public async Task <IActionResult> GetAllBlogsPaged([FromQuery] BlogQuery searchQuery) { var result = await _blogService.GetAllBlogsPaged(searchQuery); return(Ok(result)); }
public void GetTotalRowCount() { var query = new BlogQuery(_dbFactory); Assert.AreEqual(_defaultData.Count, query.GetTotalRowCount()); }
/// <summary> /// 取得 Blog /// </summary> /// <param name="condition">查詢條件</param> /// <returns></returns> public async Task <IEnumerable <Blog> > GetAsync(BlogQuery condition) { var blogs = await _context.Blog.ToListAsync(); return(blogs); }