public List <WarframeItem> AdvancedSearch(AdvancedSearchModel model)
        {
            List <ItemCache> ics = new ItemCacheRepository(_unitOfWork).AdvancedSearch(model);

            string test = "[" + string.Join(",", ics.Select(x => x.Data)) + "]";

            return(JsonConvert.DeserializeObject <List <WarframeItem> >(test));
        }
        public WarframeItem GetByUniqueName(string uniqueName, bool redownloadCacheIfNotFound = true)
        {
            ItemCache itemCache = new ItemCacheRepository(_unitOfWork).GetByUniqueName(uniqueName);

            if (redownloadCacheIfNotFound && itemCache == null || itemCache.UpdatedTimestamp < DateTime.Now.AddDays(-2))
            {
                itemCache = RedownloadCache().SingleOrDefault(x => x.UniqueName == uniqueName);
            }
            return(JsonConvert.DeserializeObject <WarframeItem>(itemCache.Data));
        }
        public List <WarframeItem> GetByName(string name)
        {
            List <ItemCache> caches = new ItemCacheRepository(_unitOfWork).GetByName(name);

            if (caches.SafeAny() && caches.First().UpdatedTimestamp < DateTime.Now.AddDays(-2))
            {
                caches = RedownloadCache().Where(x => x.Name == name).ToList();
            }
            string test = "[" + string.Join(",", caches.Select(x => x.Data)) + "]";

            return(JsonConvert.DeserializeObject <List <WarframeItem> >(test));
        }
        public List <WarframeItem> GetAll()
        {
            List <ItemCache> ic = new ItemCacheRepository(_unitOfWork).GetAll();

            // Redownload Cached Items
            if (ic == null || !ic.Any() || ic.First().UpdatedTimestamp < DateTime.Now.AddDays(-2))
            {
                ic = RedownloadCache();
            }
            string test = "[" + string.Join(",", ic.Select(x => x.Data)) + "]";

            return(JsonConvert.DeserializeObject <List <WarframeItem> >(test));
        }
        public List <WarframeItem> GetByCategoryIDs(IEnumerable <int> itemCategoriesIDs)
        {
            List <ItemCache> ics = new ItemCacheRepository(_unitOfWork).GetByItemCategoryIDs(itemCategoriesIDs);

            // Redownload Cached Items
            if (ics == null || !ics.Any() || ics.First().UpdatedTimestamp < DateTime.Now.AddDays(-2))
            {
                ics = RedownloadCache().Where(x => itemCategoriesIDs.Contains(x.ItemCategoryID)).ToList();
            }
            string test = "[" + string.Join(",", ics.Select(x => x.Data)) + "]";

            return(JsonConvert.DeserializeObject <List <WarframeItem> >(test));
        }
        public List <WarframeItem> GetByCodexSection(CodexSection codexSection)
        {
            List <ItemCache> caches = new ItemCacheRepository(_unitOfWork).GetByCodexSection(codexSection);

            if (caches == null && !caches.Any() || caches.First().UpdatedTimestamp < DateTime.Now.AddDays(-2))
            {
                List <ItemCategory> itemCategories = new ItemCategoryRepository(_unitOfWork).GetByCodexSection(codexSection);
                caches = RedownloadCache().Where(x => itemCategories.Select(y => y.ID).Contains(x.ItemCategoryID)).ToList();
            }
            string test = "[" + string.Join(",", caches.Select(x => x.Data)) + "]";

            return(JsonConvert.DeserializeObject <List <WarframeItem> >(test));
        }
        public List <WarframeItem> Search(string q)
        {
            List <ItemCache> ics = new ItemCacheRepository(_unitOfWork).Search(q);

            // Redownload Cached Items
            if (ics == null || !ics.Any() || ics.First().UpdatedTimestamp < DateTime.Now.AddDays(-2))
            {
                ics = RedownloadCache().Where(x => x.Name.Contains(q)).ToList();
            }
            string test = "[" + string.Join(",", ics.Select(x => x.Data)) + "]";

            return(JsonConvert.DeserializeObject <List <WarframeItem> >(test));
        }
Пример #8
0
        private string GetItemName(ItemCacheRepository repo, string uniqueName)
        {
            if (string.IsNullOrWhiteSpace(uniqueName))
            {
                return(string.Empty);
            }

            ItemCache cache = repo.GetByUniqueName(uniqueName);

            if (cache == null)
            {
                return(string.Empty);
            }
            else
            {
                return(cache.Name);
            }
        }