public int CreateGraphForCustomer(AuthenticationState authState, string graphName) { var dataGraph = new DataGraphInstance() { CustomerId = authState.User.GetCustomerId(), Name = graphName }; _context.DataGraph.Add(dataGraph); // Configure the global object var globalObj = new DataGraphObject() { UserId = "", ObjectType = "Global", Graph = dataGraph }; _context.Objects.Add(globalObj); _context.SaveChanges(); dataGraph.GlobalObjectId = globalObj.ObjectId; _context.SaveChanges(); // Respond with the graph ID return(dataGraph.Id); }
public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } DataGraphInstance = await _context.DataGraph.FirstOrDefaultAsync(m => m.CustomerId == id); if (DataGraphInstance == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } DataGraphInstance = await _context.DataGraph.FindAsync(id); if (DataGraphInstance != null) { _context.DataGraph.Remove(DataGraphInstance); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }