// DELETE: odata/Person(5) public async Task <IHttpActionResult> Delete([FromODataUri] System.Guid key) { var p = new Person(); await Mongo.CreatePersonAsync(p); return(StatusCode(HttpStatusCode.NoContent)); }
// POST: odata/Person public async Task <IHttpActionResult> Post(Person person) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // TODO: Add create logic here. var p = new Person(); p.Name = "peng"; p.CreatedDate = DateTimeOffset.Now; p.Id = Guid.NewGuid(); await Mongo.CreatePersonAsync(p); return(Created(person)); }
public async Task <IHttpActionResult> Patch([FromODataUri] System.Guid key, Delta <Person> delta) { Validate(delta.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // TODO: Get the entity here. // delta.Patch(person); // TODO: Save the patched entity. var person = new Person(); await Mongo.CreatePersonAsync(person); return(Updated(person)); }
// PUT: odata/Person(5) public async Task <IHttpActionResult> Put([FromODataUri] System.Guid key, Delta <Person> delta) { Validate(delta.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var p = new Person(); await Mongo.CreatePersonAsync(p); // TODO: Get the entity here. // delta.Put(person); // TODO: Save the patched entity. // return Updated(person); return(StatusCode(HttpStatusCode.NotImplemented)); }