//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); }
public fTag DeleteFTag(fTag tag) { return tagAccessor.DeleteFTag(tag); }
public fTag UpdateFTag(fTag tag) { return tagAccessor.UpdateFTag(tag); }
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; }
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; }
public fTag DeleteFTag(fTag tag) { VestnDB db = new VestnDB(); db.fTag.Attach(tag); tag = db.fTag.Remove(tag); db.SaveChanges(); return tag; }