Exemple #1
0
 public sTag DeleteSTag(sTag tag)
 {
     return tagAccessor.DeleteSTag(tag);
 }
Exemple #2
0
 public sTag UpdateSTag(sTag tag)
 {
     return tagAccessor.UpdateSTag(tag);
 }
Exemple #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);
 }
Exemple #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;
 }
Exemple #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;
 }
Exemple #6
0
        public sTag DeleteSTag(sTag tag)
        {
            VestnDB db = new VestnDB();
            db.sTag.Attach(tag);
            tag = db.sTag.Remove(tag);
            db.SaveChanges();

            return tag;
        }