Exemplo n.º 1
0
        public virtual ActionResult GetStructuresTreeNode()
        {
            try
            {
                List <JObject> jobjects = new List <JObject>();

                var items = _univercityStructureService.GetAllUnivercityStructures();

                if (items.Any())
                {
                    var rootNodes = items.Where(c => c.Level == 1);
                    foreach (var node in rootNodes)
                    {
                        JObject root = new JObject
                        {
                            { "id", node.Id },
                            { "text", node.Name },
                            { "hasChild", node.HasChild },
                            { "level", node.Level }
                        };
                        root.Add("children", this.GetChild(node, items));
                        jobjects.Add(root);
                    }
                }
                return(Content(JsonConvert.SerializeObject(jobjects)));
            }
            catch (Exception)
            {
                return(Json(new { isError = true, Msg = "خطا در لود ساختار دانشگاه" }));
            }
        }
Exemplo n.º 2
0
        public virtual ActionResult GetDepartmentJson()
        {
            try
            {
                var structures = _univercityStructure.GetAllUnivercityStructures();

                JArray ja = new JArray();

                foreach (var item in structures)
                {
                    var itemObject = new JObject
                    {
                        { "StructId", item.Id },
                        { "StructName", item.Name }
                    };
                    ja.Add(itemObject);
                }
                return(Content(JsonConvert.SerializeObject(ja), "application/json"));
            }
            catch (Exception)
            {
                return(Json(new { isError = true, Msg = "خطا در لود دپارتمان" }));
            }
        }