public JsonResult GetTree() { var nodeList = new List <OulankaTreeNode>(); var cadenas = _cadenaService.GetList().OrderBy(x => x.Nombre); foreach (var cadena in cadenas) { var node = new OulankaTreeNode { Id = cadena.Id, Text = cadena.Nombre, NodeType = "cadena" }; var locales = _localService.GetList(cadena.Id); foreach (var local in locales) { node.Nodes.Add(new OulankaTreeNode { Id = local.Id, Text = local.Nombre, ParentId = cadena.Id, NodeType = "local" }); } nodeList.Add(node); } return(Json(nodeList, JsonRequestBehavior.AllowGet)); }
public async Task <IHttpActionResult> GetList(Guid cadena) { var items = new List <LocalDto>(); try { if (await _authorizationService.AuthorizeAsync(User)) { var locales = _localService.GetList(cadena, true); items = Mapper.Map <IEnumerable <Local>, List <LocalDto> >(locales); } } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok(new { items })); }