Пример #1
0
        public async Task<ActionResult> MainNewsSearch()
        {
            return await Task.Run(() =>
            {
                var result = TopNewsBL.Instance.SelectAll(DateTime.Now.AddDays(-1), DateTime.Now, string.Empty);
                var viewModel = new MainNewsListFilter
                {
                    DateFrom = DateTime.Now.AddDays(-1),
                    DateTo = DateTime.Now,
                    IsActive = false,
                    IsApproved = false,
                    Header = string.Empty
                };

                viewModel.NewsList = new ConcurrentBag<ITopNews>();
                result.ToList().AsParallel().ForAll(news => viewModel.NewsList.Add(news));

                return View(viewModel);
            });
        }
Пример #2
0
        public async Task<ActionResult> MainNewsSearch(MainNewsListFilter criteria)
        {
            return await Task.Run(() =>
            {
                var result = TopNewsBL.Instance.SelectAll(criteria.DateFrom, criteria.DateTo, criteria.Header);

                if (criteria.IsActive)
                {
                    result = result.ToList().FindAll(news => news.IsActive == 1);
                }

                if (criteria.IsApproved)
                {
                    result = result.ToList().FindAll(news => news.IsApproved == 1);
                }

                criteria.NewsList = new ConcurrentBag<ITopNews>();
                result.ToList().AsParallel().ForAll(news => criteria.NewsList.Add(news));

                return View(criteria);
            });
        }