public IHttpActionResult PutStoreTree(int id, StoreTree storeTree) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != storeTree.ID) { return(BadRequest()); } db.Entry(storeTree).State = EntityState.Modified; try { db.SaveChanges(); var subscribed = Hub.Clients.Group(storeTree.Name.ToLower()); subscribed.updateItem(storeTree); } catch (DbUpdateConcurrencyException) { if (!StoreTreeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetStoreTree(int id) { StoreTree storeTree = db.StoreTrees.Find(id); if (storeTree == null) { return(NotFound()); } return(Ok(storeTree)); }
public IHttpActionResult PostStoreTree(StoreTree storeTree) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StoreTrees.Add(storeTree); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = storeTree.ID }, storeTree)); }
// POST: odata/StoreTreesOD public IHttpActionResult Post(StoreTree storeTree) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StoreTrees.Add(storeTree); db.SaveChanges(); return(Created(storeTree)); }
private void LoadTreeStore() { //dont select tree, get the tree node from current zone content //assuming the parent is a zone type for now ZoneTree parentTree = (ZoneTree)gameDataObject.treeStore.getCurrentTree(); ZoneTreeNode parentTreeNode = (ZoneTreeNode)parentTree.getNode(parentTree.currentIndex); long storeLink = parentTreeNode.content.linkIndex; parentTreeLink = gameDataObject.treeStore.currentTreeIndex; gameDataObject.treeStore.SelectTree(storeLink); storeTree = (StoreTree)gameDataObject.treeStore.getCurrentTree(); }
public IHttpActionResult DeleteStoreTree(int id) { StoreTree storeTree = db.StoreTrees.Find(id); if (storeTree == null) { return(NotFound()); } db.StoreTrees.Remove(storeTree); db.SaveChanges(); return(Ok(storeTree)); }
// DELETE: odata/StoreTreesOD(5) public IHttpActionResult Delete([FromODataUri] int key) { StoreTree storeTree = db.StoreTrees.Find(key); if (storeTree == null) { return(NotFound()); } db.StoreTrees.Remove(storeTree); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/StoreTreesOD(5) public IHttpActionResult Put([FromODataUri] int key, Delta <StoreTree> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StoreTree storeTree = db.StoreTrees.Find(key); if (storeTree == null) { return(NotFound()); } patch.Put(storeTree); try { db.SaveChanges(); var subscribed = Hub.Clients.Group(storeTree.Name.ToLower()); subscribed.updateItem(storeTree); } catch (DbUpdateConcurrencyException) { if (!StoreTreeExists(key)) { return(NotFound()); } else { throw; } } return(Updated(storeTree)); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <StoreTree> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StoreTree storeTree = db.StoreTrees.Find(key); if (storeTree == null) { return(NotFound()); } patch.Patch(storeTree); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StoreTreeExists(key)) { return(NotFound()); } else { throw; } } return(Updated(storeTree)); }
public static ITree getTreeFromString(string data, TreeType treeType, GlobalFlags gf) { ITree t = null; List <ITreeNode> treeNodeList = null; switch (treeType) { case TreeType.World: WorldTree worldTree = new WorldTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList); worldTree.currentIndex = treeNodeList[0].index; t = worldTree; break; case TreeType.Zone: ZoneTree zoneTree = new ZoneTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList); zoneTree.currentIndex = treeNodeList[0].index; t = zoneTree; break; case TreeType.Dialog: DialogTree dialogTree = new DialogTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList); dialogTree.currentIndex = treeNodeList[0].index; t = dialogTree; break; case TreeType.Quest: QuestTree questTree = new QuestTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList); questTree.currentIndex = treeNodeList[0].index; t = questTree; break; case TreeType.Battle: BattleTree battleTree = new BattleTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); battleTree.treeNodeDictionary = getBattleTreeNodeFromList(treeNodeList); battleTree.currentIndex = treeNodeList[0].index; t = battleTree; break; case TreeType.Info: InfoTree infoTree = new InfoTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); infoTree.treeNodeDictionary = getInfoTreeNodeFromList(treeNodeList); infoTree.currentIndex = treeNodeList[0].index; t = infoTree; break; case TreeType.Store: StoreTree storeTree = new StoreTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); storeTree.treeNodeDictionary = getStoreTreeNodeFromList(treeNodeList); storeTree.currentIndex = treeNodeList[0].index; t = storeTree; break; case TreeType.Cutscene: CutsceneTree cutsceneTree = new CutsceneTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); cutsceneTree.treeNodeDictionary = getCutsceneTreeNodeFromList(treeNodeList); cutsceneTree.currentIndex = treeNodeList[0].index; t = cutsceneTree; break; default: break; } return(t); }
public static ITree getTreeFromString(string data, TreeType treeType, GlobalFlags gf) { ITree t = null; List<ITreeNode> treeNodeList = null; switch (treeType) { case TreeType.World: WorldTree worldTree = new WorldTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList); worldTree.currentIndex = treeNodeList[0].index; t = worldTree; break; case TreeType.Zone: ZoneTree zoneTree = new ZoneTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList); zoneTree.currentIndex = treeNodeList[0].index; t = zoneTree; break; case TreeType.Dialog: DialogTree dialogTree = new DialogTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList); dialogTree.currentIndex = treeNodeList[0].index; t = dialogTree; break; case TreeType.Quest: QuestTree questTree = new QuestTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList); questTree.currentIndex = treeNodeList[0].index; t = questTree; break; case TreeType.Battle: BattleTree battleTree = new BattleTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); battleTree.treeNodeDictionary = getBattleTreeNodeFromList(treeNodeList); battleTree.currentIndex = treeNodeList[0].index; t = battleTree; break; case TreeType.Info: InfoTree infoTree = new InfoTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); infoTree.treeNodeDictionary = getInfoTreeNodeFromList(treeNodeList); infoTree.currentIndex = treeNodeList[0].index; t = infoTree; break; case TreeType.Store: StoreTree storeTree = new StoreTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); storeTree.treeNodeDictionary = getStoreTreeNodeFromList(treeNodeList); storeTree.currentIndex = treeNodeList[0].index; t = storeTree; break; case TreeType.Cutscene: CutsceneTree cutsceneTree = new CutsceneTree(gf, treeType); treeNodeList = getTreeNodeListFromString(data, treeType); cutsceneTree.treeNodeDictionary = getCutsceneTreeNodeFromList(treeNodeList); cutsceneTree.currentIndex = treeNodeList[0].index; t = cutsceneTree; break; default: break; } return t; }