Skip to content

Commit fc29e67

Browse files
committed
Merge pull request #81 from csantero/type-property
Add type property and key primary data at `data`
2 parents b83f0df + 9f76960 commit fc29e67

File tree

49 files changed

+281
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+281
-89
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Collections.Generic;
2+
using System.Data.Entity;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using System.Web.Http;
6+
using JSONAPI.EntityFramework.Tests.TestWebApp.Models;
7+
8+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Controllers
9+
{
10+
public class SearchController : ApiController
11+
{
12+
private readonly TestDbContext _dbContext;
13+
14+
public SearchController(TestDbContext dbContext)
15+
{
16+
_dbContext = dbContext;
17+
}
18+
19+
public async Task<IEnumerable<object>> Get(string s)
20+
{
21+
IEnumerable<object> posts = await _dbContext.Posts.Where(p => p.Title.Contains(s)).ToArrayAsync();
22+
IEnumerable<object> comments = await _dbContext.Comments.Where(p => p.Text.Contains(s)).ToArrayAsync();
23+
return posts.Concat(comments);
24+
}
25+
}
26+
}

JSONAPI.EntityFramework.Tests.TestWebApp/JSONAPI.EntityFramework.Tests.TestWebApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
<Content Include="Web.config" />
116116
</ItemGroup>
117117
<ItemGroup>
118+
<Compile Include="Controllers\SearchController.cs" />
118119
<Compile Include="Controllers\CommentsController.cs" />
119120
<Compile Include="Controllers\UserGroupsController.cs" />
120121
<Compile Include="Controllers\UsersController.cs" />
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"data": [
3+
{
4+
"type": "posts",
5+
"id": "201",
6+
"title": "Post 1",
7+
"content": "Post 1 content",
8+
"created": "2015-01-31T14:00:00+00:00",
9+
"links": {
10+
"author": "401",
11+
"comments": [ "101", "102", "103" ],
12+
"tags": [ "301", "302" ]
13+
}
14+
},
15+
{
16+
"type": "comments",
17+
"id": "101",
18+
"text": "Comment 1",
19+
"created": "2015-01-31T14:30:00+00:00",
20+
"links": {
21+
"author": "403",
22+
"post": "201"
23+
}
24+
}
25+
]
26+
}

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PostRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "205",
56
"title": "Added post",
67
"content": "Added post content",

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PutWithArrayRelationshipValueRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "202",
56
"links": {
67
"tags": ["301"]

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PutWithAttributeUpdateRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "202",
56
"title": "New post title"
67
}

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PutWithMissingToManyIdsRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "202",
56
"links": {
67
"tags": {

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PutWithMissingToManyTypeRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "202",
56
"links": {
67
"tags": {

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PutWithMissingToOneIdRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "202",
56
"links": {
67
"author": {

JSONAPI.EntityFramework.Tests/Acceptance/Fixtures/Posts/Requests/PutWithMissingToOneTypeRequest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"posts": [
2+
"data": [
33
{
4+
"type": "posts",
45
"id": "202",
56
"links": {
67
"author": {

0 commit comments

Comments
 (0)