示例#1
0
        public bool AddVal(string value, int weight = 0)
        {
            foreach (AttributeVal av in val)
            {
                if (av.value == value)
                {
                    // AttributeValue already exists
                    return(false);
                }
            }
            AttributeVal nav = new AttributeVal();

            nav.value  = value;
            nav.weight = weight;
            val.Add(nav);
            return(true);
        }
示例#2
0
        public JsonResult EditAttribute(int id)
        {
            var attribute = db.AbtributeAndValues.Where(s => s.post_id == id).ToList();
            List <AttributeVal> listAttributes = new List <AttributeVal>();
            AttributeVal        tmp            = null;

            foreach (var item in attribute)
            {
                tmp               = new AttributeVal();
                tmp.id            = item.id;
                tmp.value         = item.value;
                tmp.post_id       = item.post_id;
                tmp.atribute_id   = item.atribute_id;
                tmp.atribute_name = db.Atributes.Where(s => s.atribute_id == item.atribute_id).Select(s => s.atribute_name).FirstOrDefault();
                listAttributes.Add(tmp);
            }
            return(Json(new
            {
                data = listAttributes,
                status = true
            }));
        }