public async Task <IActionResult> Get()
        {
            StructureProvider provider = new StructureProvider();

            var obj = provider.GenerateData();

            System.IO.File.WriteAllText("data.json", JsonConvert.SerializeObject(obj));

            return(Ok(new[] { "" }));
        }
        private async Task <IActionResult> GetQuery(string entity = "Tables", string query = null)
        {
            List <JObject> objects;

            if (query == null)
            {
                dynamic Projects = new JObject();
                Projects.Item         = "Location Structure";
                Projects.DisplayName  = "Location Structure";
                Projects.Id           = "Location";
                Projects.IsFavorite   = false;
                Projects.ProviderName = "DCM";
                Projects.Source       = "xxxx";;
                Projects.IsDraggable  = false;
                Projects.IsClickable  = true;
                Projects.IsLeaf       = false;
                Projects.Type         = string.Empty;
                objects = new List <JObject>();
                objects.Add(Projects);

                dynamic p2 = new JObject();
                p2.Item         = "Room";
                p2.DisplayName  = "Room";
                p2.Id           = "Room";
                p2.IsFavorite   = false;
                p2.ProviderName = "DCM";
                p2.Source       = "Room";;
                p2.IsDraggable  = true;
                p2.IsClickable  = true;
                p2.IsLeaf       = true;
                p2.Type         = "GRID";
                dynamic DS = new JObject();
                DS.DataSource = "History?sourceid=room";
                p2.History    = DS;
                if (entity != "Projects")
                {
                    objects.Add(p2);
                }

                dynamic p3 = new JObject();
                p3.Item         = "Room Temperature";
                p3.DisplayName  = "Room Temperature";
                p3.Id           = "RoomTemperature";
                p3.IsFavorite   = false;
                p3.ProviderName = "DCM";
                p3.Source       = "RoomTemperature";
                p3.IsDraggable  = true;
                p3.IsClickable  = true;
                p3.IsLeaf       = true;
                p3.Type         = "GRID";
                dynamic DS1 = new JObject();
                DS1.DataSource = "History?sourceid=RoomTemperature";
                p3.History     = DS1;
                if (entity != "Projects")
                {
                    objects.Add(p3);
                }
            }
            else if (query.Split('/').Last() == "Variables")
            {
                dynamic p2 = new JObject();
                p2.Item         = "Total Power";
                p2.DisplayName  = "Total Power";
                p2.Id           = "Total Power";
                p2.IsFavorite   = false;
                p2.ProviderName = "Properties";
                p2.Source       = "Total Power";
                p2.IsDraggable  = true;
                p2.IsClickable  = true;
                p2.IsLeaf       = true;
                p2.Type         = "LIST_VALUE";
                objects         = new List <JObject>();
                dynamic DS = new JObject();
                DS.DataSource = "History?sourceid=room";
                p2.History    = DS;
                objects.Add(p2);
            }
            else
            {
                objects = GenerateJson(StructureProvider.Getprovider().Execute(query));
                //if(entity=="Variables" && objects[0].Type.ToString()=="Rack")
                //{

                dynamic p2 = new JObject();
                p2.Item         = "Variables";
                p2.DisplayName  = "Variables";
                p2.Id           = "Variables";
                p2.IsFavorite   = false;
                p2.ProviderName = "Variables";
                p2.Source       = "Variables";;
                p2.IsDraggable  = false;
                p2.IsClickable  = true;
                p2.IsLeaf       = false;
                p2.Type         = "";
                //}
                if (entity != "Tables")
                {
                    objects.Add(p2);
                }
            }


            CustomDataProvider customDataProvider = new CustomDataProvider
            {
                Entity      = entity,
                Truncated   = false,
                SearchItems = objects
            };

            string outputString = JsonConvert.SerializeObject(customDataProvider);

            var jArr = JObject.Parse(outputString);

            jArr.Capitalize();

            return(Ok(jArr));
        }