public IActionResult CollectionsList(int?topic, string name)
        {
            IQueryable <Collection> collections = db.Collections.Include(p => p.Topic);

            if (topic != null && topic != 0)
            {
                collections = collections.Where(p => p.TopicId == topic);
            }
            if (!String.IsNullOrEmpty(name))
            {
                collections = collections.Where(p => p.Name.Contains(name));
            }

            List <Topic> topics = db.Topics.ToList();

            topics.Insert(0, new Topic {
                Name = "Все", Id = 0
            });

            CollectionListViewModel viewModel = new CollectionListViewModel {
                Collections = collections.ToList(),
                Topics      = new SelectList(topics, "Id", "Name"),
                Name        = name
            };

            return(View(viewModel));
        }
Пример #2
0
        public ActionResult Index()
        {
            CollectionListViewModel model = new CollectionListViewModel();

            model.InstanceListViewModel.Instances = Service.GetCollections();
            return(View(model));
        }