Example #1
0
        public IPagedList<Log> GetEntriesPaged(LogSearchQuery searchQuery)
        {
            using (new SiteFilterDisabler(_session))
            {
                IQueryOver<Log, Log> query = BaseQuery();
                if (searchQuery.Type.HasValue)
                    query = query.Where(log => log.Type == searchQuery.Type);

                if (!string.IsNullOrWhiteSpace(searchQuery.Message))
                    query =
                        query.Where(
                            log =>
                                log.Message.IsInsensitiveLike(searchQuery.Message, MatchMode.Anywhere));

                if (!string.IsNullOrWhiteSpace(searchQuery.Detail))
                    query = query.Where(log => log.Detail.IsInsensitiveLike(searchQuery.Detail, MatchMode.Anywhere));

                if (searchQuery.SiteId.HasValue)
                    query = query.Where(log => log.Site.Id == searchQuery.SiteId);

                if (searchQuery.From.HasValue)
                    query = query.Where(log => log.CreatedOn >= searchQuery.From);
                if (searchQuery.To.HasValue)
                    query = query.Where(log => log.CreatedOn <= searchQuery.To);

                return query.Paged(searchQuery.Page);
            }
        }
Example #2
0
 public ViewResult Index(LogSearchQuery searchQuery)
 {
     ViewData["site-options"] = _adminService.GetSiteOptions();
     ViewData["logs"] = _adminService.GetEntriesPaged(searchQuery);
     return View(searchQuery);
 }