Example #1
0
 public ActionResult List(int? page, Search search)
 {
     IEnumerable<users> requestedUsers = DataBase.Users.Get();
     if (!page.HasValue)
         page = 1;
     if (search == null)
         ViewBag.Search = new Search();
     else
     {
         ViewBag.Search = search;
         requestedUsers= DataBase.Users.Search(search);
     }
     var requestedUsersView = requestedUsers.Select(u => new UserView(u)).AsQueryable();
     var a = new PageableData<UserView>(requestedUsersView, (int)page, 15);
     return View("List", a);
 }
Example #2
0
            public static IEnumerable<mission> Search(Search search)
            {
                var requestedMissions = context.mission.AsEnumerable();
                if (!string.IsNullOrWhiteSpace(search.word))
                    requestedMissions = requestedMissions.Where(x => x.description.Contains(search.word) || x.title.Contains(search.word));
                if (search.category.HasValue)
                    requestedMissions = requestedMissions.Where(x => x.cid == search.category.Value);
                if (search.city.HasValue)
                    requestedMissions = requestedMissions.Where(x => x.cityID == search.city.Value);
                if (search.language.HasValue)
                    requestedMissions = requestedMissions.Where(x => x.users.userLanguages.Any(l => l.lid == search.language));
                if (search.priceFirst.HasValue)
                    requestedMissions = requestedMissions.Where(x => x.price > search.priceFirst);
                if (search.priceSecond.HasValue)
                    requestedMissions = requestedMissions.Where(x => x.price < search.priceSecond);

                return requestedMissions;
            }
Example #3
0
            public static IEnumerable<users> Search(Search search)
            {
                var requestedUsers = context.users.AsEnumerable();
                if (!string.IsNullOrWhiteSpace(search.word))
                    requestedUsers = requestedUsers.Where(x => x.about.Contains(search.word) || x.description.Contains(search.word) || x.name.Contains(search.word));
                if (search.category.HasValue)
                    requestedUsers = requestedUsers.Where(x => x.agent_categories.Any(ac => ac.cid == search.category.Value));
                if (search.city.HasValue)
                    requestedUsers = requestedUsers.Where(x => x.cityID == search.city.Value);
                if (search.language.HasValue)
                    requestedUsers = requestedUsers.Where(x => x.userLanguages.Any(l => l.lid == search.language));
                if (search.priceFirst.HasValue)
                    requestedUsers = requestedUsers.Where(x => x.price > search.priceFirst);
                if (search.priceSecond.HasValue)
                    requestedUsers = requestedUsers.Where(x => x.price < search.priceSecond);

                return requestedUsers;
            }