public ActionResult Index(DefaultModel model) { DateTime startDate = model.StartDate > DateTime.MinValue ? new DateTime(model.StartDate.Year, model.StartDate.Month, model.StartDate.Day, 0, 0, 0) : DateTime.MinValue; DateTime endDate = model.EndDate > DateTime.MinValue ? new DateTime(model.EndDate.Year, model.EndDate.Month, model.EndDate.Day, 23, 59, 59) : DateTime.MinValue; var data = _service.Find(!string.IsNullOrEmpty(model.SearchText), o => o.Name.Contains(model.SearchText) || o.Type.Contains(model.SearchText)) .Where(!string.IsNullOrEmpty(model.ID), o => o.ID == model.ID) .Where(string.IsNullOrEmpty(model.Record), o => o.ParentID.Equals("0")) .Where(!string.IsNullOrEmpty(model.Record), o => o.ParentID == model.Record) .Where(_currentLang != null, o => o.LangID == _currentLang.ID) .Where(startDate > DateTime.MinValue, o => o.Created >= startDate) .Where(endDate > DateTime.MinValue, o => o.Created <= endDate) .OrderByDescending(o => o.ID) .ToList(); ViewBag.Data = data.Skip(model.PageSize * model.PageIndex).Take(model.PageSize).ToList(); model.TotalRecord = data.Count; ViewBag.Model = model; return(View()); }