Esempio n. 1
0
        public async Task <IActionResult> Find(AdvertisementsIndexViewModel model)
        {
            model.Title ??= "";
            model.Diploma ??= "";
            model.WorkAddress ??= "";
            model.Contract ??= "";
            model.Experience ??= "";
            model.Field ??= "";
            model.Searched = true;
            var query = db.Advertisements.Where(x => x.Title.Contains(model.Title) &&
                                                x.Field.Contains(model.Field) &&
                                                x.WorkAddress.Contains(model.WorkAddress) &&
                                                x.Diploma.Contains(model.Diploma) &&
                                                x.Contract.Contains(model.Contract) &&
                                                x.Experiance.Contains(model.Experience))
                        .OrderBy(x => x.Posted);

            model.Ads      = new PagedResult <Advertisement>();
            model.Ads.Data = await query.ToListAsync();

            model.Ads.TotalItems = await db.Advertisements.CountAsync();

            //model.Ads.PageNumber = pageNumber;
            //model.Ads.PageSize = pageSize;
            return(View("Index", model));
        }
Esempio n. 2
0
        public IActionResult Find(string title, string address)
        {
            if (String.IsNullOrEmpty(title) && String.IsNullOrEmpty(address))
            {
                return(RedirectToAction("Index"));
            }
            AdvertisementsIndexViewModel model = new AdvertisementsIndexViewModel
            {
                Title       = title,
                WorkAddress = address
            };

            return(RedirectToAction("Find", "Advertisement", model));
        }
Esempio n. 3
0
        public async Task <IActionResult> Index(int pageNumber = 1, int pageSize = 10)
        {
            AdvertisementsIndexViewModel model = new AdvertisementsIndexViewModel();

            model.Searched = false;
            int ExcludeRecords = (pageSize * pageNumber) - pageSize;
            var query          = db.Advertisements.OrderBy(x => x.Posted)
                                 .Select(p => p)
                                 .Skip(ExcludeRecords)
                                 .Take(pageSize);

            model.Ads      = new PagedResult <Advertisement>();
            model.Ads.Data = await query.ToListAsync();

            model.Ads.TotalItems = await db.Advertisements.CountAsync();

            model.Ads.PageNumber = pageNumber;
            model.Ads.PageSize   = pageSize;
            return(View(model));
        }