Skip to content

Commit 664d76a

Browse files
Updates the OData advanced example which transition to and from OData or basic Web API (#49)
1 parent dbd24b3 commit 664d76a

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

ApiVersioningWithSamples.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConventionsODataWebApiSampl
112112
EndProject
113113
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ConventionsSample", "samples\aspnetcore\ConventionsSample\ConventionsSample.xproj", "{1EFC221F-35CF-4B55-BD59-240D5B808E14}"
114114
EndProject
115+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Acceptance.Tests", "test\Microsoft.AspNet.WebApi.Acceptance.Tests\Microsoft.AspNet.WebApi.Acceptance.Tests.xproj", "{5C31964D-EA8B-420B-9297-5ADFEFE54962}"
116+
EndProject
117+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Acceptance.Tests", "test\Microsoft.AspNetCore.Mvc.Acceptance.Tests\Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj", "{4EED304C-D1A6-4866-8D7F-450D084FD25D}"
118+
EndProject
115119
Global
116120
GlobalSection(SolutionConfigurationPlatforms) = preSolution
117121
Debug|Any CPU = Debug|Any CPU
@@ -174,6 +178,14 @@ Global
174178
{1EFC221F-35CF-4B55-BD59-240D5B808E14}.Debug|Any CPU.Build.0 = Debug|Any CPU
175179
{1EFC221F-35CF-4B55-BD59-240D5B808E14}.Release|Any CPU.ActiveCfg = Release|Any CPU
176180
{1EFC221F-35CF-4B55-BD59-240D5B808E14}.Release|Any CPU.Build.0 = Release|Any CPU
181+
{5C31964D-EA8B-420B-9297-5ADFEFE54962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
182+
{5C31964D-EA8B-420B-9297-5ADFEFE54962}.Debug|Any CPU.Build.0 = Debug|Any CPU
183+
{5C31964D-EA8B-420B-9297-5ADFEFE54962}.Release|Any CPU.ActiveCfg = Release|Any CPU
184+
{5C31964D-EA8B-420B-9297-5ADFEFE54962}.Release|Any CPU.Build.0 = Release|Any CPU
185+
{4EED304C-D1A6-4866-8D7F-450D084FD25D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
186+
{4EED304C-D1A6-4866-8D7F-450D084FD25D}.Debug|Any CPU.Build.0 = Debug|Any CPU
187+
{4EED304C-D1A6-4866-8D7F-450D084FD25D}.Release|Any CPU.ActiveCfg = Release|Any CPU
188+
{4EED304C-D1A6-4866-8D7F-450D084FD25D}.Release|Any CPU.Build.0 = Release|Any CPU
177189
EndGlobalSection
178190
GlobalSection(SolutionProperties) = preSolution
179191
HideSolutionNode = FALSE
@@ -200,5 +212,7 @@ Global
200212
{C1F89961-7134-4D97-BA3A-2693FD1CBF4E} = {F446ED94-368F-4F67-913B-16E82CA80DFC}
201213
{9A22600C-7768-4D16-B67D-514F55942FAF} = {F446ED94-368F-4F67-913B-16E82CA80DFC}
202214
{1EFC221F-35CF-4B55-BD59-240D5B808E14} = {900DD210-8500-4D89-A05D-C9526935A719}
215+
{5C31964D-EA8B-420B-9297-5ADFEFE54962} = {0987757E-4D09-4523-B9C9-65B1E8832AA1}
216+
{4EED304C-D1A6-4866-8D7F-450D084FD25D} = {0987757E-4D09-4523-B9C9-65B1E8832AA1}
203217
EndGlobalSection
204218
EndGlobal

samples/webapi/AdvancedODataWebApiSample/Controllers/Orders3Controller.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,15 @@
44
using Models;
55
using System.Threading.Tasks;
66
using System.Web.Http;
7-
using System.Web.OData;
8-
using System.Web.OData.Query;
9-
using System.Web.OData.Routing;
107

11-
// note: even though this version of the controller uses attribute routing, other controllers use convention-based
12-
// routing. if we don't apply the ControllerName attribute, then the "controller" route parameter is not populated,
13-
// which will cause version 1.0 and 2.0 to not be discovered since they are convention-based.
148
[ApiVersion( "3.0" )]
159
[ControllerName( "Orders" )]
16-
[RoutePrefix( "api/orders" )]
1710
public class Orders3Controller : ApiController
1811
{
1912
// GET ~/orders?api-version=3.0
20-
[Route]
2113
public IHttpActionResult Get() => Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } } );
2214

2315
// GET ~/orders/{id}?api-version=3.0
24-
[Route( "{id}" )]
2516
public IHttpActionResult Get( int id ) => Ok( new Order() { Id = id, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } );
2617
}
2718
}

samples/webapi/AdvancedODataWebApiSample/Controllers/OrdersController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
using Models;
55
using System.Threading.Tasks;
66
using System.Web.Http;
7-
using System.Web.OData;
8-
using System.Web.OData.Query;
9-
using System.Web.OData.Routing;
107

118
// note: since the application is configured with AssumeDefaultVersionWhenUnspecifed, this controller
129
// is implicitly versioned to the DefaultApiVersion, which has the default value 1.0.

samples/webapi/AdvancedODataWebApiSample/Startup.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public void Configuration( IAppBuilder appBuilder )
1919
var configuration = new HttpConfiguration();
2020
var httpServer = new HttpServer( configuration );
2121

22-
configuration.MapHttpAttributeRoutes();
2322
configuration.AddApiVersioning(
2423
o =>
2524
{
@@ -51,7 +50,6 @@ public void Configuration( IAppBuilder appBuilder )
5150

5251
configuration.MapVersionedODataRoutes( "odata", "api", models, batchHandler );
5352
configuration.Routes.MapHttpRoute( "orders", "api/{controller}/{id}", new { id = Optional } );
54-
5553
appBuilder.UseWebApi( httpServer );
5654
}
5755
}

0 commit comments

Comments
 (0)