public ActionResult SelectQasForeignKeys() { SelectQasFKs setForeignKeys = new SelectQasFKs(); setForeignKeys.Advertises = advertiseService.GetAdvertises(); setForeignKeys.SubDomains = subDomainService.GetSubDomains(); return(View(setForeignKeys)); }
public ActionResult Advertises(string stringSearch, string sortOrder, string currentFilter, int page = 1) { Log.Debug("Started getting all the advertises"); var getAdvertises = advertiseService.GetAdvertises(); SearchingAndPagingViewModel <Advertise> model = new SearchingAndPagingViewModel <Advertise> { Collection = getAdvertises.OrderBy(p => p.Title).Skip((page - 1) * PageSize).Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = stringSearch == null?getAdvertises.Count() : getAdvertises.Count(s => s.Title.Contains(stringSearch)) }, SortingOrder = IsNullOrEmpty(sortOrder) ? "end_date" : "", SearchString = stringSearch }; switch (sortOrder) { case "end_date": model.Collection = model.Collection.OrderByDescending(s => s.CreateDate); break; default: // Name ascending model.Collection = model.Collection.OrderBy(s => s.CreateDate); break; } if (!IsNullOrEmpty(stringSearch)) { model.Collection = getAdvertises.Where(s => s.Title.Contains(stringSearch) || s.User.UserName.Contains(stringSearch) || s.City.Contains(stringSearch)); } return(View(model)); }