コード例 #1
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        public ActionResult TimelineData(Guid? id, string text)
        {
            BasicNodeModel model = null;

            using (NeoDriver driver = new NeoDriver())
            {
                if(!id.HasValue || id == Guid.Empty)
                {
                    model = driver.GetNode(text);
                }
                else
                {
                    model = driver.GetNode(id.Value);
                }
            }

            return Json(new { success = model != null,  ReleaseDate = model?.ReleaseDate, DeathDate = model?.DeathDate }, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        public ActionResult GetNodeInformation(Guid id)
        {
            BasicNodeModel model = new BasicNodeModel();
            if(id != Guid.Empty)
            {
                using (NeoDriver driver = new NeoDriver())
                {
                    model = driver.GetNode(id);
                }
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
ファイル: EditController.cs プロジェクト: Error503/Capstone
        public ActionResult FlagDeletion(Guid id)
        {
            string message = "An error occurred. The node was not flagged";

            Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            BasicNodeModel toDelete = null;

            using (NeoDriver driver = new NeoDriver())
            {
                toDelete = driver.GetNode(id);
            }

            // If the node with the given id is not null,
            if (toDelete != null)
            {
                DatabaseRequest request = new DatabaseRequest
                {
                    Id             = Guid.NewGuid(),
                    RequestType    = DatabaseRequestType.Delete,
                    SubmissionDate = DateTime.Now,
                    NodeDataType   = toDelete.ContentType,
                    NodeData       = JsonConvert.SerializeObject(BasicNodeViewModel.FromModel(toDelete)),
                    Approved       = false,
                    ApprovalDate   = null,
                    Notes          = null,
                    Reviewed       = false,
                    ReviewedDate   = null,
                    Reviewer       = null,
                    ReviewerRefId  = null
                };

                // Add a deletion request,
                using (ApplicationDbContext context = ApplicationDbContext.Create())
                {
                    request.Submitter = context.Users.Single(u => u.UserName == User.Identity.Name);
                    context.Requests.Add(request);
                    context.SaveChanges();
                }

                message             = "Node flagged for deletion";
                Response.StatusCode = (int)HttpStatusCode.Accepted;
            }
            else
            {
                message             = "Could not find the specified node.";
                Response.StatusCode = (int)HttpStatusCode.NotFound;
            }

            return(Json(new { message = message }));
        }
コード例 #4
0
ファイル: EditController.cs プロジェクト: Error503/Capstone
        private ActionResult CheckModelAndMakeRequest(BasicNodeViewModel model)
        {
            ActionResult result = View("Index", model);

            // If the model state is valid,
            if (ModelState.IsValid)
            {
                DatabaseRequestType requestType = 0;
                using (NeoDriver driver = new NeoDriver())
                {
                    // TODO: This will no longer work to check if this is an update or creation request
                    requestType = driver.GetNode(model.Id) != null ? DatabaseRequestType.Update : DatabaseRequestType.Create;
                }
                // Create the database request
                CreateDatabaseRequest(model, requestType);
                // Redirect to the accepted page
                result = RedirectToAction("Accepted", "Edit");
            }

            return(result);
        }
コード例 #5
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        private GraphDataViewModel GetPaths(Guid? id, string searchText)
        {
            GraphDataViewModel result = null;
            // Get the paths from the database
            List<IPath> paths = new List<IPath>();
            using (NeoDriver driver = new NeoDriver())
            {
                if(id == null || id == Guid.Empty)
                {
                    paths = driver.GetPaths(searchText.ToLower());
                }
                else
                {
                    paths = driver.GetPaths(id.Value);
                }

                if(paths.Count == 0)
                {
                    BasicNodeModel model = id == null || id == Guid.Empty ? driver.GetNode(searchText) : driver.GetNode(id.Value);

                    if(model != null)
                    {
                        result.Source = new GraphNodeViewModel
                        {
                            Id = model.Id.ToString(),
                            CommonName = model.CommonName,
                            DataType = model.ContentType
                        };
                        result.RelatedNodes = new List<GraphNodeViewModel>();
                    }
                }
                else
                {
                    result = ConvertFromPaths(paths);
                }
            }

            return result;
        }