public ActionResult SearchResult(string catUrl, string parameters, int page) { HttpCookie httpCookie = base.HttpContext.Request.Cookies.Get("system_search"); if (!base.Request.Cookies.ExistsCokiee("system_search")) { return(base.View()); } Expression <Func <Post, bool> > expression = PredicateBuilder.True <Post>(); SortBuilder sortBuilder = new SortBuilder() { ColumnName = "CreatedDate", ColumnOrder = SortBuilder.SortOrder.Descending }; Paging paging = new Paging() { PageNumber = page, PageSize = base._pageSize, TotalRecord = 0 }; SeachConditions seachCondition = JsonConvert.DeserializeObject <SeachConditions>(base.Server.UrlDecode(httpCookie.Value)); expression = expression.And <Post>((Post x) => (int?)x.MenuId == seachCondition.CategoryId); MenuLink byId = this._menuLinkService.GetById(seachCondition.CategoryId.Value); ((dynamic)base.ViewBag).KeyWords = byId.MetaKeywords; ((dynamic)base.ViewBag).SiteUrl = base.Url.Action("GetContent", "Menu", new { catUrl = catUrl, parameters = parameters, page = page, area = "" }); ((dynamic)base.ViewBag).Description = byId.MetaDescription; ((dynamic)base.ViewBag).Image = base.Url.Content(string.Concat("~/", byId.ImageUrl)); ((dynamic)base.ViewBag).VirtualId = byId.CurrentVirtualId; string menuName = byId.MenuName; if (!string.IsNullOrEmpty(seachCondition.Keywords)) { expression = expression.And <Post>((Post x) => x.Title.Contains(seachCondition.Keywords) || x.Description.Contains(seachCondition.Keywords)); } IEnumerable <Post> posts = this._postService.FindAndSort(expression, sortBuilder, paging); ((dynamic)base.ViewBag).PageNumber = page; ((dynamic)base.ViewBag).Title = menuName; if (posts.IsAny <Post>()) { Helper.PageInfo pageInfo = new Helper.PageInfo(ExtentionUtils.PageSize, page, paging.TotalRecord, (int i) => base.Url.Action("GetContent", "Menu", new { page = i })); ((dynamic)base.ViewBag).PageInfo = pageInfo; ((dynamic)base.ViewBag).CountItem = pageInfo.TotalItems; } return(base.View("GetPostByCategory", posts)); }
public ActionResult Search(SeachConditions conditions) { var objCondition = JsonConvert.SerializeObject(conditions); var cookie = new HttpCookie("system_search", objCondition) { Expires = DateTime.Now.AddDays(1.0) }; Response.Cookies.Add(cookie); var byId = new MenuLink(); var menuLinks = _menuLinkService.GetByOption(isDisplayHomePage: true, template: new List <int> { (int)TemplateContent.Product }); if (menuLinks.IsAny()) { byId = menuLinks.FirstOrDefault(); } return(RedirectToAction("SearchResult", "Post", new { catUrl = byId?.SeoUrl, parameters = conditions.Keywords.NonAccent(), area = "" })); }
public ActionResult SearchMenu() { var seachConditions = new SeachConditions(); return(PartialView(seachConditions)); }