Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        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"));
        }