Exemplo n.º 1
0
        public ActionResult Index(string price, string alphabet, string topicId)
        {
            var editions = _editionRepository.GetAll().Where(a => a.EditionStatus == EditionStatus.Active);

            Guid.TryParse(topicId, out Guid topicIdGuid);

            if (!String.IsNullOrWhiteSpace(topicId))
            {
                editions = _editionRepository.GetAll().Where(a => a.TopicId == topicIdGuid);
            }

            if (price == "Asc")
            {
                editions = editions.OrderBy(a => a.EditionPrice).ToList();
            }
            else if (price == "Desc")
            {
                editions = editions.OrderByDescending(a => a.EditionPrice).ToList();
            }

            if (alphabet == "Asc")
            {
                editions = editions.OrderBy(a => a.EditionTitle).ToList();
            }
            else if (alphabet == "Desc")
            {
                editions = editions.OrderByDescending(a => a.EditionTitle).ToList();
            }

            Dictionary <EditionModel, IEnumerable <ArticleModel> > editionsAndArticles = new Dictionary <EditionModel, IEnumerable <ArticleModel> >();

            foreach (var edition in editions)
            {
                editionsAndArticles.Add(edition, _editionRepository.GetArticles(edition.EditionId));
            }


            ViewBag.Editions = editionsAndArticles;


            return(View());
        }
Exemplo n.º 2
0
 public List <Edition> getAllEditions()
 {
     return(editionRepository.GetAll());
 }