// POST api/marks public HttpResponseMessage Post(Mark value) { var created = this.markRepository.Add(value); var responce = Request.CreateResponse<Mark>(HttpStatusCode.Created, created); var resourceLink = Url.Link("DefaultApi", new { id = created.Id }); responce.Headers.Location = new Uri(resourceLink); return responce; }
// PUT api/marks/5 public HttpResponseMessage Put(int id, Mark value) { if (id != value.Id || value == null) { return new HttpResponseMessage(HttpStatusCode.BadRequest); } var updated = this.markRepository.Update(id, value); var responce = Request.CreateResponse<Mark>(HttpStatusCode.Created, updated); var resourceLink = Url.Link("DefaultApi", new { id = updated.Id }); responce.Headers.Location = new Uri(resourceLink); return responce; }