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;
        }
Exemplo n.º 2
0
 public void UpdateOrAdd(Person person)
 {
     Remove(person.FirstName, person.LastName);
     Add(person);            
 }
Exemplo n.º 3
0
 public void Add(Person p)
 {
     _people.Add(p);
 }
Exemplo n.º 4
0
        public IHttpActionResult PutPerson([FromODataUri] string firstName, [FromODataUri] string lastName, Person person)
        {
            _repo.UpdateOrAdd(person);

            return Updated(person);
        }
Exemplo n.º 5
0
 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);
        }