public ActionResult AdvertismentsList(SiteMVC.Models.Engine.AdvertismentsRequest request)
        {
            AdvertismentsList advertisments;

            if (!string.IsNullOrEmpty(Request["page"]))
            {
                int currentPage;
                if (!int.TryParse(Request["page"], out currentPage) || currentPage < 1)
                {
                    currentPage = 1;
                }

                request.Offset = (currentPage - 1) * request.Limit;
            }

            var advertismentsLoader = new AdvertismentsLoader();

            if (request.Date == null)
            {
                advertismentsLoader.SetTodayDate(request);

                advertisments = advertismentsLoader.LoadAdversitments(request);
                if (!advertismentsLoader.IsLoaded(advertisments))
                {
                    advertismentsLoader.SetYesterdayDate(request);
                    advertisments = advertismentsLoader.LoadAdversitments(request);
                }
            }
            else
            {
                advertisments = advertismentsLoader.LoadAdversitments(request);
            }

            advertisments.Offset = request.Offset;
            advertisments.Limit  = request.Limit;

            return(PartialView(advertisments));
        }
Beispiel #2
0
        public IEnumerable <ExternalAdvertisment> KharkovCapital_RentAdvertisments()
        {
            var advertismentsLoader = new AdvertismentsLoader();

            var request = new AdvertismentsRequest()
            {
                State        = State.NotSubpurchase,
                SectionId    = 1, //--- rent appartments
                SubSectionId = 1, //--- only rent
                Offset       = 0,
                Limit        = 500,
                Filter       = new AdvertismentsFilter()
                {
                    OnlyNew = true
                }
            };

            advertismentsLoader.SetTodayDate(request);

            AdvertismentsList advertismentsList = advertismentsLoader.LoadAdversitments(request);

            if (advertismentsList == null || advertismentsList.Advertisments == null)
            {
                return(null);
            }

            return(advertismentsList.Advertisments
                   .Select(a =>
            {
                return new ExternalAdvertisment()
                {
                    Text = a.Text,
                    Price = a.Price
                };
            }));
        }