示例#1
0
 public sTag DeleteSTag(sTag tag)
 {
     return tagAccessor.DeleteSTag(tag);
 }
示例#2
0
 public sTag UpdateSTag(sTag tag)
 {
     return tagAccessor.UpdateSTag(tag);
 }
示例#3
0
 //set parentId to 0 when it is at the top level
 public sTag CreateSTag(int parentId, string value)
 {
     sTag tag = new sTag();
     tag.value = value;
     tag.parentId = parentId;
     try
     {
         VestnDB db = new VestnDB();
         db.sTag.Add(tag);
         db.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         return null;//bad id
     }
     return (tag);
 }
示例#4
0
 private sTag GetEntitySTag(string value)
 {
     VestnDB db = new VestnDB();
     sTag tag = new sTag();
     try
     {
         tag = db.sTag.Where(u => u.value == value).First();
     }
     catch (Exception e)
     {
         return null;
     }
     return tag;
 }
示例#5
0
 public sTag UpdateSTag(sTag tag)
 {
     sTag oldTag = GetSTag(tag.id);
     if (oldTag.value != tag.value)
     {
         return tag;
     }
     try
     {
         VestnDB db = new VestnDB();
         db.Entry(tag).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         return null;
     }
     return tag;
 }
示例#6
0
        public sTag DeleteSTag(sTag tag)
        {
            VestnDB db = new VestnDB();
            db.sTag.Attach(tag);
            tag = db.sTag.Remove(tag);
            db.SaveChanges();

            return tag;
        }