Ejemplo n.º 1
0
        // GET: blogs/search
        public async Task <IActionResult> search(string term)
        {
            if (term == null)
            {
                return(Redirect("/blogs"));
            }

            var _sanitize = new HtmlSanitizer();

            term = _sanitize.Sanitize(UtilityBLL.ReplaceHyphinWithSpace(term));

            /* ***************************************/
            // Process Page Meta & BreaCrumb
            /* ***************************************/
            var _meta = PageMeta.returnPageMeta(new PageQuery()
            {
                controller = ControllerContext.ActionDescriptor.ControllerName,
                index      = ControllerContext.ActionDescriptor.ActionName,
                pagenumber = 1,
                matchterm  = term
            });

            if (Jugnoon.Settings.Configs.GeneralSettings.store_searches)
            {
                //*********************************************
                // User Search Tracking Script
                //********************************************
                if (!TagsBLL.Validate_Tags(term.Trim()) && !term.Trim().Contains("@"))
                {
                    // check if tag doesn't exist
                    var count_tags = await TagsBLL.Count(_context, new TagEntity()
                    {
                        type      = TagsBLL.Types.General,
                        tag_type  = TagsBLL.TagType.UserSearches,
                        isenabled = EnabledTypes.Enabled
                    });

                    if (count_tags == 0)
                    {
                        TagsBLL.Add(_context, term.Trim(), TagsBLL.Types.General, 0, TagsBLL.TagType.UserSearches, EnabledTypes.Enabled, term.Trim());
                    }
                }
            }

            /* List Initialization */
            var ListEntity = new BlogListViewModel()
            {
                QueryOptions = new BlogEntity()
                {
                    term = term,
                },
                BreadItems = _meta.BreadItems
            };


            return(View(ListEntity));
        }
        public async Task <ActionResult> load()
        {
            var json   = new StreamReader(Request.Body).ReadToEnd();
            var data   = JsonConvert.DeserializeObject <TagEntity>(json);
            var _posts = await TagsBLL.LoadItems(_context, data);

            var _records = 0;

            if (data.id == 0)
            {
                _records = await TagsBLL.Count(_context, data);
            }
            return(Ok(new { posts = _posts, records = _records }));
        }