public IActionResult AddNode([FromBody] Node node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } try { _nodeService.AddNode(node); _session.Cancel(); return(Ok()); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
private void AddNodeToModel(DataNode dataNode, int stamp) { NodeName nodeName = dataNode.Name; Node node = new Node(nodeName) { Stamp = stamp, NodeType = dataNode.NodeType, Description = dataNode.Description }; node.Bounds = dataNode.Bounds; node.ScaleFactor = dataNode.Scale; node.Color = dataNode.Color; node.IsNodeHidden = dataNode.ShowState == Node.Hidden; Node parentNode = GetParentNode(nodeName, dataNode); nodeService.AddNode(node, parentNode); }
public ActionResult AddEdit(Node model) { if (Session["UserId"] != null) { if (ModelState.IsValid) { var isNodeExist = _nodeService.IsNodeExist(model.NodeId, model.NodeName); if (!isNodeExist) { try { int userId = Convert.ToInt32(Session["UserId"].ToString()); model.CreatedBy = userId; int i = 0; if (model.NodeId > 0) { i = _nodeService.UpdateNode(model); TempData["Node"] = "Updated"; } else { i = _nodeService.AddNode(model); TempData["Node"] = "Inserted"; var nodelist = _nodeService.GetNodeDataByGatewayId(model.GatewayId); foreach (var n in nodelist) { if (n.NodeName == model.NodeName) { model.NodeId = n.NodeId; break; } } } if (i > 0) { SendMessage(TempData["Node"].ToString(), model.GatewayId, model.NodeId, model.NodeName); return(RedirectToAction("Index")); } else { TempData["Node"] = null; return(View("AddEditNode", model)); } } catch (Exception ex) { throw ex; } } else { ModelState.Clear(); ModelState.AddModelError("", "Node already Exist"); model.GatewayList = _gatewayService.GetGatewayList(); return(View("AddEditNode", model)); } } else { return(RedirectToAction("AddNode")); } } else { return(RedirectToAction("Login", "Home")); } }
public JsonResult Nodes([FromBody] Node node) { return(Json(m_nodeService.AddNode(node))); }