public ActionResult Index(Search model, int page = 1, int pageSize = 10) { var data = SearchService.SearchAll(model.Name, model.CatID).ToList(); foreach (var item in data) { item.PageExt = page; item.PageSizeExt = pageSize; item.TotalPageExt = (int)Math.Ceiling((float)data.Count / (float)item.PageSizeExt); item.CountItemExt = data.Count(); item.CatID = model.CatID; } data = data.OrderByDescending(x => x.Name).Skip((page - 1) * pageSize).Take(pageSize).ToList(); ViewBag.TitleName = model.Name; return View(data); }
public IList<Search> SearchAll(string value, long catId) { try { IList<Search> lst = new List<Search>(); var picexaminee = new List<Examinee>(); picexaminee = ExamineeEntity.GetMany( c => StringHelper.RemoveVietNamString(c.Description.ToLower()).Contains(StringHelper.RemoveVietNamString(value)) || StringHelper.RemoveVietNamString(c.UserNameExt.ToLower()).Contains(StringHelper.RemoveVietNamString(value)), Table.Examinee.ToString()).ToList(); if (picexaminee != null) { foreach (var item in picexaminee) { Search s = new Search(); s.Name = item.UserNameExt; s.Type = "Nhà sản xuất"; s.Image = "/Media/PictureExam/" + item.Image; s.Link = "Examinee/detail/" + item.ID + "?username="******"Bài viết"; s.Image = "/Media/Article/" + item.Image; s.Link = "article/detail/" + item.ID; s.Description = item.ShortDescription; lst.Add(s); } } return lst; } catch { return null; } }
/// <summary> /// Search Input Control on Header /// </summary> /// <param name="value"></param> /// <returns></returns> public ActionResult _SearchInputControl() { var data = SearchService.GetSelectListCategory(); Search cat = new Search(); if (data != null) { cat.ListCategoryExt = data; } return PartialView(cat); }