Esempio n. 1
0
        public ActionResult Search(NewsArticlesModel subscribersModel)
        {
            var ReturnUrl = Request.Form["ReturnUrl"];
            var search    = Request.Form["search"];

            if (search == null)
            {
                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }

            search = AppFunctions.CleanString(search);
            Regex rgx = new Regex("[^a-zA-Z0-9 -]");

            search = rgx.Replace(search, "");

            Response.Redirect("~/Home/Search/?q=" + search);
            return(RedirectToAction("Search/?q=" + search, "Home"));
        }
Esempio n. 2
0
        //Search
        public ActionResult Search()
        {
            var ReturnUrl = Request.Form["ReturnUrl"];
            var query     = Request.QueryString["q"];

            if (query == null)
            {
                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }
            query = AppFunctions.CleanString(query);

            ViewBag.Search = query;

            ViewBag.CountTotal = db.NewsArticles.Count(s => (s.ArticleTextIdentifier.Contains(query) || s.ArticleHeadline.Contains(query) || s.ArticleBody.Contains(query) || s.Tags.Contains(query)) && (s.DeleteStatus == false && s.ReviewStatus == 1));
            var data = db.NewsArticles.Where(s => (s.ArticleTextIdentifier.Contains(query) || s.ArticleHeadline.Contains(query) || s.ArticleBody.Contains(query) || s.Tags.Contains(query)) && (s.DeleteStatus == false && s.ReviewStatus == 1)).OrderByDescending(s => s.ArticleDate);

            return(View(data));
        }
Esempio n. 3
0
        //Tags
        public ActionResult Tags()
        {
            var ReturnUrl = Request.Form["ReturnUrl"];
            var tag       = Request.QueryString["tag"];

            if (tag == null)
            {
                if (!string.IsNullOrEmpty(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                return(RedirectToAction("Index", "Home"));
            }
            tag = AppFunctions.CleanString(tag);

            ViewBag.Tag = tag;

            ViewBag.CountTotal = db.NewsArticles.Count(s => (s.Tags.Contains(tag)) && (s.DeleteStatus == false && s.ReviewStatus == 1));
            var data = db.NewsArticles.Where(s => (s.Tags.Contains(tag)) && (s.DeleteStatus == false && s.ReviewStatus == 1)).OrderByDescending(s => s.ArticleDate);

            return(View(data));
        }