//AdvertismentsState advertismentState, DateTime dateTimeFrom, DateTime dateTimeTo, int sectionId = 1, int? subSectionId = null, int offset = 0, int limit = 100
    private AdvertismentsResponse LoadAdversitments(Nedvijimost.AdvertismentsRequest requestParameters)
    {
        IQueryable <Advertisment> advertisments = FilterAdversitments(requestParameters.DateFrom.Value, requestParameters.DateTo.Value);
        int advertismentsCount       = 0;
        int advertismentsToShowCount = 0;

        if (advertisments != null)
        {
            advertisments = advertisments.Where(adv => adv.AdvertismentSection_Id == requestParameters.SectionId);

            if (requestParameters.SubSectionId != null)
            {
                advertisments = advertisments.Where(adv => adv.AdvertismentSubSection.Id == requestParameters.SubSectionId.Value);
            }

            advertismentsCount = advertisments.Count();

            switch (requestParameters.State)
            {
            case AdvertismentsState.JustParsed:
                advertisments = advertisments.Where(
                    adv => adv.subpurchaseAdvertisment && adv.SubPurchase_Id == null
                    );
                break;

            case AdvertismentsState.NotSubpurchase:
                advertisments = advertisments.Where(
                    adv => !adv.subpurchaseAdvertisment
                    );
                break;

            case AdvertismentsState.Subpurchase:
                advertisments = advertisments.Where(
                    adv => adv.subpurchaseAdvertisment && adv.SubPurchase_Id != null
                    );
                break;

            case AdvertismentsState.SubpurchaseWithNotSubpurchase:
                advertisments = advertisments.Where(
                    adv => !adv.subpurchaseAdvertisment || adv.SubPurchase_Id != null
                    );
                break;
            }

            advertismentsToShowCount = advertisments.Count();

            //--- special filters
            if (requestParameters.OnlyWithPhotos)
            {
                advertisments = advertisments.Where(adv => adv.AdvertismentsPhotos.Any());
            }

            advertisments = advertisments.Skip(requestParameters.Offset).Take(requestParameters.Limit);
        }

        return(FormatResultAdversitments(advertisments, advertismentsCount, advertismentsToShowCount));
    }
    public AdvertismentsResponse LoadAdvertisments(Nedvijimost.AdvertismentsRequest request)
    {
        if (request.Date == null)
        {
            AdvertismentsResponse adversitmentsAndFullParsedCount = LoadTodayAdversitments(request);
            if (AdvertismentsNotLoaded(adversitmentsAndFullParsedCount))
            {
                adversitmentsAndFullParsedCount = LoadYesterdayAdversitments(request);
            }

            return(adversitmentsAndFullParsedCount);
        }
        else
        {
            return(LoadAdversitments(request));
        }
    }
 private AdvertismentsResponse LoadYesterdayAdversitments(Nedvijimost.AdvertismentsRequest request)
 {
     request.DateFrom = Utils.GetUkranianDateTimeNow().AddDays(-1).Date;
     request.DateTo   = Utils.GetUkranianDateTimeNow().Date;
     return(LoadAdversitments(request));
 }