示例#1
0
 public IHttpActionResult GetRoot()
 {
     try
     {
         return(Ok(service.GetTree()));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(BadRequest());
     }
 }
示例#2
0
        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"));
        }
示例#3
0
        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));
        }
示例#4
0
        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);
        }
示例#5
0
        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());
        }
示例#6
0
        public IActionResult Index(string errorId, string errorMsg)
        {
            var vm = treeService.GetTree();

            if (errorId != null)
            {
                ModelState.AddModelError(errorId, errorMsg);
                return(View(vm));
            }

            return(View(vm));
        }
示例#7
0
        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());
        }