Пример #1
0
        public void LoadPage(int pageNumber, bool excludeReadItems)
        {
            try
            {
                this.IsLoading = true;

                UpdateReadItems(excludeReadItems);

                if (PagedItemViewModels.Count >= pageNumber * AppConfig.ITEM_COUNT_PER_FEED)
                {
                    return;
                }

                if (pageNumber == 1)
                {
                    PagedItemViewModels.Clear();
                }

                int skip     = (pageNumber - 1) * AppConfig.ITEM_COUNT_PER_FEED;
                var itemPage = excludeReadItems ?
                               AllItemViewModels.Where(i => !i.Read).Skip(skip).Take(AppConfig.ITEM_COUNT_PER_FEED).ToList()
                    : AllItemViewModels.Skip(skip).Take(AppConfig.ITEM_COUNT_PER_FEED).ToList();

                itemPage.ForEach(i => PagedItemViewModels.Add(i));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                this.IsLoading = false;
            }
        }
Пример #2
0
        public void Initialize()
        {
            AllItemViewModels.Clear();
            var savedResult = _feedManager.GetStoredItems();

            if (!savedResult.HasError)
            {
                savedResult.Target.ForEach(i => AllItemViewModels.Add(new ItemViewModel(i)));
            }
        }
Пример #3
0
        public void UpdateReadItems(bool excludeReadItems)
        {
            if (AllItemViewModels == null || AllItemViewModels.Count == 0)
            {
                return;
            }

            AllItemViewModels.ForEach(r =>
            {
                var itemViewModel = PagedItemViewModels.FirstOrDefault(i => i.Id.Equals(r.Id));
                if (itemViewModel != null)
                {
                    itemViewModel.Read = r.Read;

                    if (excludeReadItems && itemViewModel.Read)
                    {
                        PagedItemViewModels.Remove(itemViewModel);
                    }
                }
            });
        }