public HttpResponseMessage Post(CategoryView view) { var model = view.getModel(repo); 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 void Put(CategoryView view) { var model = view.getModel(repo); repo.update(model); }
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); } }