Beispiel #1
0
        // 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));
        }
Beispiel #2
0
        // 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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        // 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));
        }