예제 #1
0
 public Boolean HasProperty(String propertyref)
 {
     var objGrpCtrl = new GrpCatController(_lang);
     var l = objGrpCtrl.GetProductCategories(Info.ItemID, "!cat");
     return l.Any(i => (i.categoryref == propertyref || i.propertyref == propertyref));
 }
예제 #2
0
 public Boolean IsInCategory(String categoryref)
 {
     var objGrpCtrl = new GrpCatController(_lang);
     var l = objGrpCtrl.GetProductCategories(Info.ItemID, "cat",true);
     return l.Any(i => i.categoryref == categoryref);
 }
예제 #3
0
        /// <summary>
        /// Select categories linked to product, by groupref
        /// </summary>
        /// <param name="groupref">groupref for select, "" = all, "cat"= Category only, "!cat" = all non-category, "{groupref}"=this group only</param>
        /// <param name="cascade">get all cascade records to get all parent categories</param>
        /// <returns></returns>
        public List<GroupCategoryData> GetCategories(String groupref = "",Boolean cascade = false)
        {
            if (Info == null) return new List<GroupCategoryData>(); // stop throwing an error no product exists,

            var objGrpCtrl = new GrpCatController(_lang);
            var catl = objGrpCtrl.GetProductCategories(Info.ItemID, groupref, cascade);
            if (Utils.IsNumeric(DataRecord.GetXmlProperty("genxml/defaultcatid")) && catl.Count > 0)
            {
                var objl = catl.Where(i => i.isdefault == true);
                foreach (var i in objl)
                {
                    i.isdefault = false;
                }
                var dcatid = Convert.ToInt32(DataRecord.GetXmlProperty("genxml/defaultcatid"));
                var obj = catl.Where(i => i.categoryid == dcatid);
                var groupCategoryDatas = obj as GroupCategoryData[] ?? obj.ToArray();
                if (groupCategoryDatas.Any()) groupCategoryDatas.First().isdefault = true;
            }
            return catl;
        }