Ejemplo n.º 1
0
        public static String GetNewsArticleImage(Object _img, Object _cats)
        {
            Telerik.OpenAccess.TrackedList <System.Guid> cats = (Telerik.OpenAccess.TrackedList <System.Guid>)_cats;
            Image img = (Image)_img;

            String imgUrl = "~/Images/CAITheme/Taxation-Audits.png";

            if (img != null)
            {
                return(img.Url);
            }
            else if (cats.Count > 0)
            {
                // lets retrieve all images assigned under categories
                List <Image> imgs = new List <Image>();
                foreach (var cat in cats)
                {
                    var content = App.WorkWith().Images().Where(ci => ci.GetValue <IList <Guid> >("Category").Contains(cat));
                    content.ForEach(a => imgs.Add(a));
                }

                if (imgs.Count > 0)
                {
                    Random rnd = new Random(DateTime.Now.Millisecond);
                    imgUrl = imgs[rnd.Next(0, imgs.Count)].Url;
                }
            }

            return(imgUrl);
        }
Ejemplo n.º 2
0
        public static String GetCategoryTitle(Object _cats)
        {
            Telerik.OpenAccess.TrackedList <System.Guid> cats = (Telerik.OpenAccess.TrackedList <System.Guid>)_cats;
            string[] ignoreCats = new string[]
            {
                "Chartered Accountants Ireland",
                "Accountancy Ireland",
                "RTP News",
                "CPD",
                "Public Sector",
                "enews",
                "Education",
                "Overseas Member",
                "RTP",
                "RTPeNews",
                "Student News",
                "Tax Representations"
            };

            if (cats.Count == 0)
            {
                return("");
            }

            var foundTaxon = "";

            for (var i = 0; i < cats.Count; i++)
            {
                Guid firstCat = cats[i];

                var taxonomyManager = TaxonomyManager.GetManager();
                var taxon           = taxonomyManager.GetTaxa <HierarchicalTaxon>().Where(t => t.Id.Equals(firstCat)).SingleOrDefault();

                if (taxon != null && !ignoreCats.Contains(taxon.Title.ToString()))
                {
                    foundTaxon = taxon.Title;
                    break;
                }
            }

            return(foundTaxon);
        }