示例#1
0
        public async Task <ActionResult <CategoriesModel> > GetCategoryResults(string q)
        {
            try
            {
                if (string.IsNullOrEmpty(q))
                {
                    return(NotFound());
                }

                string CategoryID = functions.GetCategoryID(q);

                var data = _context.vwPostsApproved.Where(s => s.PostCategory == CategoryID).OrderByDescending(s => s.ApprovalsDateAdded).Take(20);

                if (!data.Any())
                {
                    return(NoContent());
                }

                return(Ok(await data.ToListAsync()));
            }
            catch (Exception ex)
            {
                //TODO Log Error
                Console.WriteLine(ex);
                return(NotFound());
            }
        }