예제 #1
0
        public string InsertUserCustomAttr(string attrName, string attrValue)
        {
            context = HttpContext.Current;
            CustomProfileCommon profile = new CustomProfileCommon();

            if (profile.UserCustomAttr.Count > 4)
            {
                return("已超过上限,最多保存5个自定义属性");
            }
            attrName  = attrName.Trim();
            attrValue = attrValue.Trim();
            if (string.IsNullOrEmpty(attrName) || string.IsNullOrEmpty(attrValue))
            {
                return("属性名称或属性值不能为空,请检查");
            }
            List <Model.UserCustomAttr> list = profile.UserCustomAttr.GetList();

            Model.UserCustomAttr oldModel = list.Find(delegate(Model.UserCustomAttr m)
            {
                return(m.AttrValue == attrValue);
            });
            if (oldModel != null)
            {
                return("已存在记录");
            }

            Model.UserCustomAttr model = new Model.UserCustomAttr();
            model.AttrName  = attrName;
            model.AttrValue = attrValue;
            profile.UserCustomAttr.Insert(model);
            profile.Save();

            return("操作成功");
        }
예제 #2
0
 public void Insert(Model.UserCustomAttr model)
 {
     if (!list.Contains(model))
     {
         list.Add(model);
     }
 }
예제 #3
0
        public void Update(Model.UserCustomAttr model)
        {
            int i = list.FindIndex(delegate(Model.UserCustomAttr m) { return(m == model); });

            if (i >= 0)
            {
                list.IndexOf(model, i);
            }
        }
예제 #4
0
        public string DeleteUserCustomAttr(string attrName)
        {
            attrName = attrName.Trim();
            CustomProfileCommon         profile = new CustomProfileCommon();
            List <Model.UserCustomAttr> list    = profile.UserCustomAttr.GetList();

            Model.UserCustomAttr model = list.Find(delegate(Model.UserCustomAttr m) { return(m.AttrName.ToLower() == attrName.ToLower()); });
            profile.UserCustomAttr.Remove(model);
            profile.Save();

            return("操作成功");
        }
예제 #5
0
 public void Remove(Model.UserCustomAttr model)
 {
     list.RemoveAll(delegate(Model.UserCustomAttr m) { return(m == model); });
 }
예제 #6
0
 public Model.UserCustomAttr GetModel(Model.UserCustomAttr model)
 {
     return(list.Find(delegate(Model.UserCustomAttr m) { return m == model; }));
 }