public HttpResponseMessage Post(CategoryInputView view) { var model = view.getModel(); model = repo.createCategoryInput(model); view = new CategoryInputView(model); var response = Request.CreateResponse<CategoryInputView>(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.getCategoryInput(id); if (model == null) { return Request.CreateResponse(HttpStatusCode.NotFound); } else { var view = new CategoryInputView(model); return Request.CreateResponse(HttpStatusCode.OK, view); } }
public void Put(int id, CategoryInputView view) { view.id = id; var model = view.getModel(); repo.update(model); }