Exemplo n.º 1
0
        public void CanGetArticleInQuery()
        {
            CanInitializeTagirator();
            var query    = new ArticleFinder(context);
            var articles = query.GetArticlesByQuery("Врата да да я");

            Assert.NotEmpty(articles);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetArticlesByQuery([FromQuery] string query, [FromQuery] int sessionId)
        {
            var articles = await Task.Run(
                () =>
            {
                var finder = new ArticleFinder(context);
                return(finder.GetArticlesByQuery(query));
            });

            if (articles == null || !articles.Any())
            {
                return(NotFound());
            }

            var session = await(from s in context.Sessions where s.Id == sessionId select s).FirstOrDefaultAsync();

            context.SearchingQueries.Add(new SearchingQuery(query, session));

            context.SaveChangesAsync();

            return(Ok((from a in articles select new { a.Id, a.Title, Text = a.Text.Substring(0, 75) }).ToList()));
        }