private void CreateDatabaseRequest(BasicNodeViewModel model, DatabaseRequestType type) { // Check the relationships foreach (RelationshipViewModel rel in model.Relationships) { // If the referenced node does not have an id, if (!rel.TargetId.HasValue) { // Give the referenced node an id rel.TargetId = Guid.NewGuid(); // Set the value of IsNewAddition to true rel.IsNewAddition = true; } } using (ApplicationDbContext context = ApplicationDbContext.Create()) { // Get the user that submitted the request ApplicationUser submitter = context.Users.Single(x => x.UserName == User.Identity.Name); // Create the request DatabaseRequest request = new DatabaseRequest { RequestType = type, Id = Guid.NewGuid(), SubmissionDate = DateTime.Now, Submitter = submitter, NodeDataType = model.ContentType, NodeData = model.SerializeToContentType(), }; // Add the request to the database context.Requests.Add(request); context.SaveChanges(); } }
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); }