Example #1
0
        public void SaveTest()
        {
            Query query = new Query(0, 1);
            query.AddFields("Metadata");

            Ad ad = Managers.AdManager.GetAds(query).Items[0];
            Managers.MetadataManager.SaveItem(new Metadata()
            {
                AdId = ad.Id,
                UserId = 1,
                Note = "Test",
                IsFavorite = true
            });

            ad = Managers.AdManager.GetAds(query).Items[0];
            Assert.AreNotEqual(ad.Metadata, null);
            Assert.AreEqual(ad.Metadata.Note, "Test");
            Assert.AreEqual(ad.Metadata.IsFavorite, true);

            Managers.MetadataManager.SaveItem(new Metadata()
            {
                AdId = ad.Id,
                UserId = 1
            });
            ad = Managers.AdManager.GetAds(query).Items[0];
            Assert.AreEqual(ad.Metadata, null);
        }
Example #2
0
        public QueryResult<AdRealty> GetAds(string query, string priceMin, string priceMax, string sortBy, string sortDirection, string offset, string limit)
        {
            Query q = new Query();

            if (!string.IsNullOrEmpty(query))
            {
                q.AddFilter("TextFilter", query);
            }

            double? _priceMin = UriParamsHelper.ParseDouble(priceMin);
            if (_priceMin.HasValue)
            {
                q.AddFilter("PriceMin", _priceMin);
            }

            double? _priceMax = UriParamsHelper.ParseDouble(priceMax);
            if (_priceMax.HasValue)
            {
                q.AddFilter("PriceMax", _priceMax);
            }

            if (!string.IsNullOrEmpty(sortBy))
            {
                SortOrder? _sortOrder = UriParamsHelper.ParseEnum<SortOrder>(sortDirection, SortOrder.Ascending);
                q.AddSort(sortBy, _sortOrder.Value);
            }

            q.Start = UriParamsHelper.ParseInt(offset, 0);
            q.Limit = UriParamsHelper.ParseInt(limit, 100);
            q.AddFields("Metadata", "HistoryLength");

            var result = Managers.AdManager.GetAds(q);
            return new QueryResult<AdRealty>(result.Items.OfType<AdRealty>().ToList(), result.TotalCount);
        }
Example #3
0
        public MainViewModel()
        {
            TotalAdsCount = Managers.AdManager.GetAds().Count;

            Query query = new Query(0, 1);
            query.AddFilter("IsNew", true);
            NewAdsCount = Managers.AdManager.GetAds(query).TotalCount.Value;
        }
 public List<LogEntry> GetList()
 {
     Query query = new Query();
     query.AddSort("Time", SortOrder.Descending);
     return Repositories.LogEntriesRepository.GetList(query).Items;
 }
Example #5
0
 public QueryResult<Ad> GetAds(Query query)
 {
     return Repositories.AdsRepository.GetList(query);
 }
Example #6
0
 protected void FillDetails(Action<OperationState> stateCallback, Action completedCallback, CancellationToken cancelationToken)
 {
     Query query = new Query();
     query.AddFilter("DetailsDownloadStatus", DetailsDownloadStatus.NotDownloaded);
     query.AddSort("CollectDate", SortOrder.Descending);
     var ads = Repositories.AdsRepository.GetList(query).Items;
     FillDetails(stateCallback, completedCallback, cancelationToken, ads);
 }
Example #7
0
        private void StartLoadItems()
        {
            Query query = new Query();
            query.AddSort(SortBySelectedItem.Key, SortOrderSelectedItem.Key);
            query.AddFields("LinkedAdsCount");
            query.AddFields("HistoryLength");

            if (!string.IsNullOrEmpty(TextFilter))
            {
                query.AddFilter("TextFilter", TextFilter);
            }

            if (PriceMin.HasValue && PriceMin.Value > 0)
            {
                query.AddFilter("PriceMin", PriceMin.Value);
            }
            if (PriceMax.HasValue && PriceMax.Value > 0)
            {
                query.AddFilter("PriceMax", PriceMax.Value);
            }

            _loadItemsOperation.RunAsync(query);
        }