Ejemplo n.º 1
0
        public static List <News> GetAll(PaginationParameters pagination, bool allOrActivated)
        {
            var             pathNewsPhoto    = ConfigurationManager.AppSettings["pathNewsPhoto"];
            var             pathDefaultPhoto = ConfigurationManager.AppSettings["pathDefaultPhoto"];
            INewsRepository newsRepo         = new NewsRepository();
            var             allNews          = (allOrActivated)? newsRepo.GetAll(pagination).ToList(): newsRepo.GetAllActivated(pagination).ToList();

            foreach (var item in allNews)
            {
                if (item.HeadImage != "" && item.HeadImage != null)
                {
                    item.HeadImage = pathNewsPhoto + item.HeadImage;
                }
                else
                {
                    item.HeadImage = pathDefaultPhoto;
                }
            }
            return(allNews);
        }