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