Example #1
0
 //set parentId to 0 when it is at the top level
 public fTag CreateFTag(int parentId, string value)
 {
     fTag tag = new fTag();
     tag.value = value;
     tag.owner = parentId;
     try
     {
         VestnDB db = new VestnDB();
         db.fTag.Add(tag);
         db.SaveChanges();
     }
     catch (InvalidOperationException)
     {
         return null;//bad id
     }
     return (tag);
 }
Example #2
0
 public fTag DeleteFTag(fTag tag)
 {
     return tagAccessor.DeleteFTag(tag);
 }
Example #3
0
 public fTag UpdateFTag(fTag tag)
 {
     return tagAccessor.UpdateFTag(tag);
 }
Example #4
0
 private fTag GetEntityFTag(string value)
 {
     VestnDB db = new VestnDB();
     fTag tag = new fTag();
     try
     {
         tag = db.fTag.Where(u => u.value == value).First();
     }
     catch (Exception e)
     {
         return null;
     }
     return tag;
 }
Example #5
0
 public fTag UpdateFTag(fTag tag)
 {
     fTag oldTag = GetFTag(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;
 }
Example #6
0
        public fTag DeleteFTag(fTag tag)
        {
            VestnDB db = new VestnDB();
            db.fTag.Attach(tag);
            tag = db.fTag.Remove(tag);
            db.SaveChanges();

            return tag;
        }