public IHttpActionResult GetRoot() { try { return(Ok(service.GetTree())); } catch (Exception ex) { Console.WriteLine(ex); return(BadRequest()); } }
public async Task <ActionResult> CreatePageNearTree(EventDto eventDto) { // to jest zjebane, ale dziala, w eventDto.Id jest id drzewa eventDto.Tree = await treeService.GetTree(eventDto.Id); Event @event = Services.AutoMapper.Instance.Map <EventDto, Event>(eventDto); var user = await userService.GetUser(User.Identity.GetUserId()); eventDto.Organizer = user; eventDto.Participants = new List <UserDto> { user }; await eventService.AddEvent(eventDto); return(RedirectToAction("Index", "Home")); }
public HttpResponseMessage Index( [System.Web.Mvc.ModelBinder(typeof(Grit.Utility.Web.Json.JsonNetModelBinder))] Envelope envelope) { var client = ClientService.GetClient(envelope.Id); if (client == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Client not found")); } var decrypted = EnvelopeService.PublicDecrypt(envelope, client.PublicKey); var req = JsonConvert.DeserializeObject <SettingsRequest>(decrypted); if (req.Client != envelope.Id) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid client")); } var tree = TreeService.GetTree(Constants.TREE_NODE); SettingsResponse settings = NodeService.GetClientSettings(client, tree) .Filter(req.Pattern); string json = JsonConvert.SerializeObject(settings); Envelope resp = EnvelopeService.Encrypt(client.Name, json, client.PublicKey); return(Request.CreateResponse(HttpStatusCode.OK, resp)); }
public async Task TestTreeService() { ITreeService treeService = new TreeService(null); await treeService.InitializeAsync(); var tree = treeService.GetTree(); Assert.AreEqual("C-1", tree[0].id); Assert.AreEqual("第1章 极限与连续(523题)", tree[0].text); Assert.AreEqual("1-1", tree[0].children[0].id); }
public ActionResult Index() { var nodes = NodeService.GetNodes(); var root = TreeService.GetTree(Constants.TREE_NODE); ViewBag.Tree = new Grit.Tree.JsTree.JsTreeBuilder <Node>( x => x.Name, x => x.NodeId) .Build(root, nodes) .children; return(View()); }
public IActionResult Index(string errorId, string errorMsg) { var vm = treeService.GetTree(); if (errorId != null) { ModelState.AddModelError(errorId, errorMsg); return(View(vm)); } return(View(vm)); }
public ActionResult Map() { var clients = ClientService.GetClients(); var leftTree = new Grit.Tree.Node(1); ViewBag.LeftTree = new Grit.Tree.JsTree.JsTreeBuilder <Settings.Model.Client>(x => x.Name, x => x.ClientId, x => x.Nodes) .Build(leftTree, clients) .children; var nodes = NodeService.GetNodes(); var rightTree = TreeService.GetTree(Constants.TREE_NODE); ViewBag.RightTree = new Grit.Tree.JsTree.JsTreeBuilder <Node>(x => x.Name, x => x.NodeId) .Build(rightTree, nodes) .children; return(View()); }