public Node GetTree() { var categories = repo.getAllCategories(); var categoryViews = CategoryView.getViews(categories); Node tree = new Node(); constructTree(tree, categoryViews.ToArray(), null); return(tree); }
public HttpResponseMessage Post(CategoryView view) { var model = view.getModel(); model = repo.createCategory(model); view = new CategoryView(model); var response = Request.CreateResponse <CategoryView>(HttpStatusCode.Created, view); string uri = Url.Route(null, new { id = view.id }); response.Headers.Location = new Uri(Request.RequestUri, uri); return(response); }
public HttpResponseMessage Get(int id) { var model = repo.getCategory(id); if (model == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } else { var view = new CategoryView(model); return(Request.CreateResponse(HttpStatusCode.OK, view)); } }
public HttpResponseMessage Children(int id) { var model = repo.getCategory(id); if (model == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } else { var subcategories = model.children; var views = CategoryView.getViews(subcategories); return(Request.CreateResponse(HttpStatusCode.OK, views)); } }
public void Put(int id, CategoryView view) { view.id = id; var model = view.getModel(); repo.update(model); }
public HttpResponseMessage Post(CategoryView view) { var model = view.getModel(); model = repo.createCategory(model); view = new CategoryView(model); var response = Request.CreateResponse<CategoryView>(HttpStatusCode.Created, view); string uri = Url.Route(null, new { id = view.id }); response.Headers.Location = new Uri(Request.RequestUri, uri); return response; }
public HttpResponseMessage Get(int id) { var model = repo.getCategory(id); if (model == null) { return Request.CreateResponse(HttpStatusCode.NotFound); } else { var view = new CategoryView(model); return Request.CreateResponse(HttpStatusCode.OK, view); } }