Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Http;
using JSONAPI.EntityFramework.Tests.TestWebApp.Models;

namespace JSONAPI.EntityFramework.Tests.TestWebApp.Controllers
{
public class SearchController : ApiController
{
private readonly TestDbContext _dbContext;

public SearchController(TestDbContext dbContext)
{
_dbContext = dbContext;
}

public async Task<IEnumerable<object>> Get(string s)
{
IEnumerable<object> posts = await _dbContext.Posts.Where(p => p.Title.Contains(s)).ToArrayAsync();
IEnumerable<object> comments = await _dbContext.Comments.Where(p => p.Text.Contains(s)).ToArrayAsync();
return posts.Concat(comments);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\SearchController.cs" />
<Compile Include="Controllers\CommentsController.cs" />
<Compile Include="Controllers\UserGroupsController.cs" />
<Compile Include="Controllers\UsersController.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data": [
{
"type": "posts",
"id": "201",
"title": "Post 1",
"content": "Post 1 content",
"created": "2015-01-31T14:00:00+00:00",
"links": {
"author": "401",
"comments": [ "101", "102", "103" ],
"tags": [ "301", "302" ]
}
},
{
"type": "comments",
"id": "101",
"text": "Comment 1",
"created": "2015-01-31T14:30:00+00:00",
"links": {
"author": "403",
"post": "201"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "205",
"title": "Added post",
"content": "Added post content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"tags": ["301"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "New post title"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"tags": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"tags": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"author": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"author": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"author": null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"author": "301"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"tags": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"tags": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"tags": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"links": {
"author": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "201",
"title": "Post 1",
"content": "Post 1 content",
Expand All @@ -12,6 +13,7 @@
}
},
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand All @@ -23,6 +25,7 @@
}
},
{
"type": "posts",
"id": "203",
"title": "Post 3",
"content": "Post 3 content",
Expand All @@ -34,6 +37,7 @@
}
},
{
"type": "posts",
"id": "204",
"title": "Post 4",
"content": "Post 4 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "204",
"title": "Post 4",
"content": "Post 4 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "205",
"title": "Added post",
"content": "Added post content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "New post title",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"posts": [
"data": [
{
"type": "posts",
"id": "202",
"title": "Post 2",
"content": "Post 2 content",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"users": [
"data": [
{
"type": "users",
"id": "401",
"firstName": "Alice",
"lastName": "Smith",
Expand All @@ -11,6 +12,7 @@
}
},
{
"type": "users",
"id": "402",
"firstName": "Bob",
"lastName": "Jones",
Expand All @@ -21,6 +23,7 @@
}
},
{
"type": "users",
"id": "403",
"firstName": "Charlie",
"lastName": "Michaels",
Expand All @@ -31,6 +34,7 @@
}
},
{
"type": "users",
"id": "409",
"firstName": "Charlie",
"lastName": "Burns",
Expand All @@ -41,6 +45,7 @@
}
},
{
"type": "users",
"id": "406",
"firstName": "Ed",
"lastName": "Burns",
Expand All @@ -51,6 +56,7 @@
}
},
{
"type": "users",
"id": "405",
"firstName": "Michelle",
"lastName": "Johnson",
Expand All @@ -61,6 +67,7 @@
}
},
{
"type": "users",
"id": "408",
"firstName": "Pat",
"lastName": "Morgan",
Expand All @@ -71,6 +78,7 @@
}
},
{
"type": "users",
"id": "404",
"firstName": "Richard",
"lastName": "Smith",
Expand All @@ -81,6 +89,7 @@
}
},
{
"type": "users",
"id": "410",
"firstName": "Sally",
"lastName": "Burns",
Expand All @@ -91,6 +100,7 @@
}
},
{
"type": "users",
"id": "407",
"firstName": "Thomas",
"lastName": "Potter",
Expand Down
Loading