コード例 #1
0
        public HttpResponseMessage GetTreeLevel(int id)
        {
            if (id <= 0)
            {
                return(Request.CreateValidationErrorResponse("Invalid parameter id"));
            }

            var context = Umbraco.TypedContent(id);

            var children = context.Children().Select(x => new TreeMenuModelItem(x)).ToList();

            var result = new TreeMenuModel {
                Children = children,
                Parent   = new TreeMenuModelItem(context)
            };

            var json = JsonConvert.SerializeObject(
                result,
                new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            return(Request.CreateResponse(HttpStatusCode.Accepted, json));
        }
コード例 #2
0
        public IActionResult Post([FromBody] TreeMenuModel param)
        {
            this.AssignModelState();
            var result = _menuService.Create(param);

            if (result.Success)
            {
                return(Ok(result.Item));
            }
            else
            {
                return(BadRequest(result.Message));
            }
        }
コード例 #3
0
        public IActionResult Put(int id, [FromBody] TreeMenuModel param)
        {
            AssignModelState();
            param.Id = id;
            var result = _menuService.Edit(param);

            if (result.Success)
            {
                return(Ok(result.Item));
            }
            else
            {
                return(BadRequest(result.Message));
            }
        }