Skip to content

Commit 550dcdd

Browse files
committed
add getting started project
1 parent d0a2c42 commit 550dcdd

File tree

12 files changed

+194
-3
lines changed

12 files changed

+194
-3
lines changed

JsonApiDotnetCore.sln

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
33
VisualStudioVersion = 15.0.27130.2010
44
MinimumVisualStudioVersion = 10.0.40219.1
@@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEntitySeparationExa
4545
EndProject
4646
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEntitySeparationExampleTests", "test\ResourceEntitySeparationExampleTests\ResourceEntitySeparationExampleTests.csproj", "{6DFA30D7-1679-4333-9779-6FB678E48EF5}"
4747
EndProject
48+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GettingStarted", "src\Examples\GettingStarted\GettingStarted.csproj", "{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}"
49+
EndProject
4850
Global
4951
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5052
Debug|Any CPU = Debug|Any CPU
@@ -187,6 +189,18 @@ Global
187189
{6DFA30D7-1679-4333-9779-6FB678E48EF5}.Release|x64.Build.0 = Release|Any CPU
188190
{6DFA30D7-1679-4333-9779-6FB678E48EF5}.Release|x86.ActiveCfg = Release|Any CPU
189191
{6DFA30D7-1679-4333-9779-6FB678E48EF5}.Release|x86.Build.0 = Release|Any CPU
192+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
193+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Debug|Any CPU.Build.0 = Debug|Any CPU
194+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Debug|x64.ActiveCfg = Debug|Any CPU
195+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Debug|x64.Build.0 = Debug|Any CPU
196+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Debug|x86.ActiveCfg = Debug|Any CPU
197+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Debug|x86.Build.0 = Debug|Any CPU
198+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Release|Any CPU.ActiveCfg = Release|Any CPU
199+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Release|Any CPU.Build.0 = Release|Any CPU
200+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Release|x64.ActiveCfg = Release|Any CPU
201+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Release|x64.Build.0 = Release|Any CPU
202+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Release|x86.ActiveCfg = Release|Any CPU
203+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71}.Release|x86.Build.0 = Release|Any CPU
190204
EndGlobalSection
191205
GlobalSection(SolutionProperties) = preSolution
192206
HideSolutionNode = FALSE
@@ -205,6 +219,7 @@ Global
205219
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
206220
{F4097194-9415-418A-AB4E-315C5D5466AF} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
207221
{6DFA30D7-1679-4333-9779-6FB678E48EF5} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
222+
{9B2A5AD7-0BF4-472E-A1B4-8BB623FDEB71} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
208223
EndGlobalSection
209224
GlobalSection(ExtensibilityGlobals) = postSolution
210225
SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.db
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using GettingStarted.Models;
2+
using JsonApiDotNetCore.Controllers;
3+
using JsonApiDotNetCore.Services;
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace GettingStarted
7+
{
8+
public class ArticlesController : JsonApiController<Article>
9+
{
10+
public ArticlesController(
11+
IJsonApiContext jsonApiContext,
12+
IResourceService<Article> resourceService,
13+
ILoggerFactory loggerFactory)
14+
: base(jsonApiContext, resourceService, loggerFactory)
15+
{ }
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using GettingStarted.Models;
2+
using JsonApiDotNetCore.Controllers;
3+
using JsonApiDotNetCore.Services;
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace GettingStarted
7+
{
8+
public class PeopleController : JsonApiController<Person>
9+
{
10+
public PeopleController(
11+
IJsonApiContext jsonApiContext,
12+
IResourceService<Person> resourceService,
13+
ILoggerFactory loggerFactory)
14+
: base(jsonApiContext, resourceService, loggerFactory)
15+
{ }
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using GettingStarted.Models;
2+
using Microsoft.EntityFrameworkCore;
3+
4+
namespace GettingStarted
5+
{
6+
public class SampleDbContext : DbContext
7+
{
8+
public SampleDbContext(DbContextOptions<SampleDbContext> options)
9+
: base(options)
10+
{ }
11+
12+
public DbSet<Article> Articles { get; set; }
13+
public DbSet<Person> People { get; set; }
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Folder Include="wwwroot\" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="../../JsonApiDotNetCore/JsonApiDotNetCore.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.0" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using JsonApiDotNetCore.Models;
2+
3+
namespace GettingStarted.Models
4+
{
5+
public class Article : Identifiable
6+
{
7+
[Attr("title")]
8+
public string Title { get; set; }
9+
10+
[HasOne("author")]
11+
public Person Author { get; set; }
12+
public int AuthorId { get; set; }
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
using JsonApiDotNetCore.Models;
3+
4+
namespace GettingStarted.Models
5+
{
6+
public class Person : Identifiable
7+
{
8+
[Attr("name")]
9+
public string Name { get; set; }
10+
11+
[HasMany("articles")]
12+
public List<Article> Articles { get; set; }
13+
}
14+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace GettingStarted
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
BuildWebHost(args).Run();
18+
}
19+
20+
public static IWebHost BuildWebHost(string[] args) =>
21+
WebHost.CreateDefaultBuilder(args)
22+
.UseStartup<Startup>()
23+
.UseUrls("http://localhost:5001")
24+
.Build();
25+
}
26+
}

src/Examples/GettingStarted/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Sample project
2+
3+
## Usage
4+
5+
`dotnet run` to run the project
6+
7+
You can verify the project is running by checking this endpoint:
8+
`localhost:5001/api/sample-model`
9+
10+
For further documentation and implementation of a JsonApiDotnetCore Application see the documentation or GitHub page:
11+
12+
Repository: https://github.com/json-api-dotnet/JsonApiDotNetCore
13+
14+
Documentation: https://json-api-dotnet.github.io/

0 commit comments

Comments
 (0)