Example #1
0
        public ViewResult Change()
        {
            AdListViewModel ads = new AdListViewModel
            {
                Advertisements = repository.Advertisements
                                 .Where(a => a.OwnerId == User.Identity.Name)
            };

            return(View(ads));
        }
Example #2
0
        public ActionResult GetAdsByCategoryId(int categoryId)
        {
            IReadOnlyCollection <Ad> ads = new List <Ad>();
            var adsResult = _adProvider.GetAdsByCategoryId(categoryId);

            if (adsResult.IsSuccess())
            {
                ads = adsResult.GetSuccessResult();
            }

            AdListViewModel model = new AdListViewModel
            {
                Ads = ads
            };

            return(View("AdList", model));
        }
Example #3
0
        public ViewResult List(int page = 1)
        {
            AdListViewModel model = new AdListViewModel
            {
                Advertisements = repository.Advertisements
                                 .OrderBy(ad => ad.AdId)
                                 .Skip((page - 1) * pageSize)
                                 .Take(pageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = pageSize,
                    TotalItems   = repository.Advertisements.Count()
                }
            };

            return(View(model));
        }