Exemplo n.º 1
0
        public Task <HttpResponseMessage> PostDerivedTypeNavigationProperty(int key, MiniSportBike vehicle)
        {
            return(Task.Factory.StartNew(() =>
            {
                new InheritanceTests_VehiclesController().LocalTable.AddOrUpdate(vehicle.Id, vehicle, (id, v) => vehicle);
                this.LocalTable[key].DerivedTypeNavigationProperty.Add(vehicle);

                var response = this.Request.CreateResponse(System.Net.HttpStatusCode.Created, vehicle);
                response.Headers.Location = new Uri(this.Url.CreateODataLink(
                                                        new EntitySetPathSegment("InheritanceTests_Vehicles"),
                                                        new KeyValuePathSegment(vehicle.Id.ToString())));
                return response;
            }));
        }
Exemplo n.º 2
0
        public Task <HttpResponseMessage> PostDerivedTypeNavigationProperty(int key, MiniSportBike vehicle)
        {
            return(Task.Factory.StartNew(() =>
            {
                new InheritanceTests_VehiclesController().LocalTable.AddOrUpdate(vehicle.Id, vehicle, (id, v) => vehicle);
                this.LocalTable[key].DerivedTypeNavigationProperty.Add(vehicle);

                IEdmEntitySet entitySet = Request.GetModel().EntityContainer.FindEntitySet("InheritanceTests_Vehicles");

                var response = this.Request.CreateResponse(System.Net.HttpStatusCode.Created, vehicle);
                response.Headers.Location = new Uri(this.Url.CreateODataLink(
                                                        new EntitySetSegment(entitySet),
                                                        new KeySegment(new[] { new KeyValuePair <string, object>("Id", vehicle.Id) }, entitySet.EntityType(), null)));
                return response;
            }));
        }
Exemplo n.º 3
0
        public Task <ITestActionResult> PostDerivedTypeNavigationProperty(int key, MiniSportBike vehicle)
        {
            return(Task <ITestActionResult> .Factory.StartNew(() =>
            {
                new InheritanceTests_VehiclesController().LocalTable.AddOrUpdate(vehicle.Id, vehicle, (id, v) => vehicle);
                this.LocalTable[key].DerivedTypeNavigationProperty.Add(vehicle);

                IEdmEntitySet entitySet = Request.GetModel().EntityContainer.FindEntitySet("InheritanceTests_Vehicles");

                string location = this.Url.CreateODataLink(
                    new EntitySetSegment(entitySet),
                    new KeySegment(new[] { new KeyValuePair <string, object>("Id", vehicle.Id) }, entitySet.EntityType(), null));

                return Created(location, vehicle);
            }));
        }