public HttpResponseMessage PostPerson(Person person) { _repo.UpdateOrAdd(person); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, person); var path = Request.GetODataPath(); string key = string.Format( "{0}={1},{2}={3}", "FirstName", ODataUriUtils.ConvertToUriLiteral(person.FirstName, Microsoft.Data.OData.ODataVersion.V3), "LastName", ODataUriUtils.ConvertToUriLiteral(person.LastName, Microsoft.Data.OData.ODataVersion.V3)); response.Headers.Location = new Uri(Url.ODataLink( new EntitySetPathSegment(path.EntitySet.Name), new KeyValuePathSegment(key))); return response; }
public void UpdateOrAdd(Person person) { Remove(person.FirstName, person.LastName); Add(person); }
public void Add(Person p) { _people.Add(p); }
public IHttpActionResult PutPerson([FromODataUri] string firstName, [FromODataUri] string lastName, Person person) { _repo.UpdateOrAdd(person); return Updated(person); }
public IHttpActionResult PostPerson(Person person) { _repo.UpdateOrAdd(person); return Created(person); }
public HttpResponseMessage PutPerson([FromODataUri] string firstName, [FromODataUri] string lastName, Person person) { _repo.UpdateOrAdd(person); return Request.CreateResponse(HttpStatusCode.OK); }