Skip to content

Commit 602d4e4

Browse files
Chris Martinezcommonsensesoftware
Chris Martinez
authored andcommitted
Clean up OData examples
1 parent b4a0cba commit 602d4e4

File tree

18 files changed

+34
-57
lines changed

18 files changed

+34
-57
lines changed

samples/aspnetcore/AdvancedODataSample/Controllers/Orders2Controller.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class Orders2Controller : ODataController
1414
public IActionResult Get( ODataQueryOptions<Order> options, ApiVersion version ) =>
1515
Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{version}" } } );
1616

17-
// GET ~/api/orders/{id}?api-version=2.0
18-
[HttpGet( "{id}" )]
19-
public IActionResult Get( int id, ODataQueryOptions<Order> options, ApiVersion version ) =>
20-
Ok( new Order() { Id = id, Customer = $"Customer v{version}" } );
17+
// GET ~/api/orders/{key}?api-version=2.0
18+
[HttpGet( "{key}" )]
19+
public IActionResult Get( int key, ODataQueryOptions<Order> options, ApiVersion version ) =>
20+
Ok( new Order() { Id = key, Customer = $"Customer v{version}" } );
2121
}
2222
}

samples/aspnetcore/AdvancedODataSample/Controllers/People2Controller.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class People2Controller : ODataController
1414
public IActionResult Get( ODataQueryOptions<Person> options, ApiVersion version ) =>
1515
Ok( new[] { new Person() { Id = 1, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } } );
1616

17-
// GET ~/api/people/{id}?api-version=3.0
18-
[HttpGet( "{id}" )]
19-
public IActionResult Get( int id, ODataQueryOptions<Person> options, ApiVersion version ) =>
20-
Ok( new Person() { Id = id, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
17+
// GET ~/api/people/{key}?api-version=3.0
18+
[HttpGet( "{key}" )]
19+
public IActionResult Get( int key, ODataQueryOptions<Person> options, ApiVersion version ) =>
20+
Ok( new Person() { Id = key, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
2121
}
2222
}

samples/aspnetcore/AdvancedODataSample/Controllers/PeopleController.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ public class PeopleController : ODataController
1717
public IActionResult Get( ODataQueryOptions<Person> options, ApiVersion version ) =>
1818
Ok( new[] { new Person() { Id = 1, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } } );
1919

20-
// GET ~/api/people/{id}
21-
// GET ~/api/people/{id}?api-version=[1.0|2.0]
22-
[HttpGet( "{id}" )]
23-
public IActionResult Get( int id, ODataQueryOptions<Person> options, ApiVersion version ) =>
24-
Ok( new Person() { Id = id, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
20+
// GET ~/api/people/{key}
21+
// GET ~/api/people/{key}?api-version=[1.0|2.0]
22+
[HttpGet( "{key}" )]
23+
public IActionResult Get( int key, ODataQueryOptions<Person> options, ApiVersion version ) =>
24+
Ok( new Person() { Id = key, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
2525

26-
// PATCH ~/api/people/{id}?api-version=2.0
27-
[HttpPatch( "{id}" )]
26+
// PATCH ~/api/people/{key}?api-version=2.0
27+
[HttpPatch( "{key}" )]
2828
[MapToApiVersion( "2.0" )]
29-
public IActionResult Patch( int id, Delta<Person> delta, ODataQueryOptions<Person> options, ApiVersion version )
29+
public IActionResult Patch( int key, Delta<Person> delta, ODataQueryOptions<Person> options, ApiVersion version )
3030
{
3131
if ( !ModelState.IsValid )
3232
return BadRequest( ModelState );
3333

34-
var person = new Person() { Id = id, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" };
34+
var person = new Person() { Id = key, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" };
3535

3636
delta.Patch( person );
3737

samples/aspnetcore/AdvancedODataSample/Models/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
6-
using System.Linq;
7-
using System.Web;
85

96
public class Order
107
{

samples/aspnetcore/AdvancedODataSample/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
65

76
public class Person

samples/aspnetcore/ConventionsODataSample/Models/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
6-
using System.Linq;
7-
using System.Web;
85

96
public class Order
107
{

samples/aspnetcore/ConventionsODataSample/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
65

76
public class Person

samples/aspnetcore/ODataBasicSample/Controllers/OrdersController.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
using Models;
77

88
[ApiVersion( "1.0" )]
9+
[ApiVersion( "2.0" )]
910
public class OrdersController : ODataController
1011
{
1112
// GET ~/v1/orders
1213
[HttpGet]
1314
public IActionResult Get( ODataQueryOptions<Order> options ) =>
1415
Ok( new[] { new Order() { Id = 1, Customer = "Bill Mei" } } );
1516

16-
// GET ~/api/v1/orders/{id}?api-version=1.0
17-
[HttpGet( "{id:int}" )]
18-
public IActionResult Get( int id, ODataQueryOptions<Order> options ) =>
19-
Ok( new Order() { Id = id, Customer = "Bill Mei" } );
17+
// GET ~/api/v1/orders/{key}?api-version=1.0
18+
[HttpGet( "{key:int}" )]
19+
public IActionResult Get( int key, ODataQueryOptions<Order> options ) =>
20+
Ok( new Order() { Id = key, Customer = "Bill Mei" } );
2021
}
2122
}

samples/aspnetcore/ODataBasicSample/Controllers/People2Controller.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class People2Controller : ODataController
1414
public IActionResult Get( ODataQueryOptions<Person> options ) =>
1515
Ok( new[] { new Person() { Id = 1, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } } );
1616

17-
// GET ~/api/people/{id}?api-version=3.0
18-
[HttpGet( "{id:int}" )]
19-
public IActionResult Get( int id, ODataQueryOptions<Person> options ) =>
20-
Ok( new Person() { Id = id, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
17+
// GET ~/api/people/{key}?api-version=3.0
18+
[HttpGet( "{key:int}" )]
19+
public IActionResult Get( int key, ODataQueryOptions<Person> options ) =>
20+
Ok( new Person() { Id = key, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
2121
}
2222
}

samples/aspnetcore/ODataBasicSample/Controllers/PeopleController.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ public class PeopleController : ODataController
1414
public IActionResult Get( ODataQueryOptions<Person> options ) =>
1515
Ok( new[] { new Person() { Id = 1, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } } );
1616

17-
// GET ~/api/people/{id}?api-version=[1.0|2.0]
18-
[HttpGet( "{id:int}" )]
19-
public IActionResult Get( int id, ODataQueryOptions<Person> options ) =>
20-
Ok( new Person() { Id = id, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
17+
// GET ~/api/people/{key}?api-version=[1.0|2.0]
18+
[HttpGet( "{key:int}" )]
19+
public IActionResult Get( int key, ODataQueryOptions<Person> options ) =>
20+
Ok( new Person() { Id = key, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" } );
2121

22-
// PATCH ~/api/people/{id}?api-version=2.0
22+
// PATCH ~/api/people/{key}?api-version=2.0
2323
[MapToApiVersion( "2.0" )]
24-
[HttpPatch( "{id:int}" )]
25-
public IActionResult Patch( int id, Delta<Person> delta, ODataQueryOptions<Person> options )
24+
[HttpPatch( "{key:int}" )]
25+
public IActionResult Patch( int key, Delta<Person> delta, ODataQueryOptions<Person> options )
2626
{
2727
if ( !ModelState.IsValid )
2828
{
2929
return BadRequest( ModelState );
3030
}
3131

32-
var person = new Person() { Id = id, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" };
32+
var person = new Person() { Id = key, FirstName = "Bill", LastName = "Mei", Email = "bill.mei@somewhere.com", Phone = "555-555-5555" };
3333

3434
delta.Patch( person );
3535

samples/aspnetcore/ODataBasicSample/Models/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
6-
using System.Linq;
7-
using System.Web;
85

96
public class Order
107
{

samples/aspnetcore/ODataBasicSample/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
65

76
public class Person

samples/webapi/AdvancedODataWebApiSample/Models/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
6-
using System.Linq;
7-
using System.Web;
85

96
public class Order
107
{

samples/webapi/AdvancedODataWebApiSample/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
65

76
public class Person

samples/webapi/BasicODataWebApiSample/Models/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
6-
using System.Linq;
7-
using System.Web;
85

96
public class Order
107
{

samples/webapi/BasicODataWebApiSample/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
65

76
public class Person

samples/webapi/ConventionsODataWebApiSample/Models/Order.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
6-
using System.Linq;
7-
using System.Web;
85

96
public class Order
107
{

samples/webapi/ConventionsODataWebApiSample/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples.Models
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.ComponentModel.DataAnnotations;
65

76
public class Person

0 commit comments

Comments
 (0)