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)); }
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)); } }
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)); } }