public IPagedList <Discount> Search(DiscountSearchQuery query) { var queryOver = _session.QueryOver <Discount>(); if (!string.IsNullOrWhiteSpace(query.DiscountCode)) { queryOver = queryOver.Where(discount => discount.Code.IsInsensitiveLike(query.DiscountCode, MatchMode.Anywhere)); } if (!string.IsNullOrWhiteSpace(query.Name)) { queryOver = queryOver.Where(discount => discount.Name.IsInsensitiveLike(query.Name, MatchMode.Anywhere)); } if (query.ShowExpired) { queryOver = queryOver.Where(discount => discount.ValidUntil < CurrentRequestData.Now || discount.ValidUntil >= CurrentRequestData.Now); } else { queryOver = queryOver.Where(discount => discount.ValidUntil >= CurrentRequestData.Now); } return(queryOver.OrderBy(discount => discount.Name).Asc.Paged(query.Page)); }
public ViewResult Index(DiscountSearchQuery searchQuery) { ViewData["results"] = _discountAdminService.Search(searchQuery); return(View(searchQuery)); }