Skip to content

Commit bbc4dea

Browse files
committed
feat(examples): add operations example
1 parent 00cbc04 commit bbc4dea

File tree

11 files changed

+509
-0
lines changed

11 files changed

+509
-0
lines changed
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
_data/
2+
3+
## Ignore Visual Studio temporary files, build results, and
4+
## files generated by popular Visual Studio add-ons.
5+
6+
# User-specific files
7+
*.suo
8+
*.user
9+
*.userosscache
10+
*.sln.docstates
11+
12+
# User-specific files (MonoDevelop/Xamarin Studio)
13+
*.userprefs
14+
15+
# Build results
16+
[Dd]ebug/
17+
[Dd]ebugPublic/
18+
[Rr]elease/
19+
[Rr]eleases/
20+
x64/
21+
x86/
22+
build/
23+
bld/
24+
[Bb]in/
25+
[Oo]bj/
26+
27+
# Visual Studio 2015 cache/options directory
28+
.vs/
29+
# Uncomment if you have tasks that create the project's static files in wwwroot
30+
#wwwroot/
31+
32+
# MSTest test Results
33+
[Tt]est[Rr]esult*/
34+
[Bb]uild[Ll]og.*
35+
36+
# NUNIT
37+
*.VisualState.xml
38+
TestResult.xml
39+
40+
# Build Results of an ATL Project
41+
[Dd]ebugPS/
42+
[Rr]eleasePS/
43+
dlldata.c
44+
45+
# DNX
46+
project.lock.json
47+
artifacts/
48+
49+
*_i.c
50+
*_p.c
51+
*_i.h
52+
*.ilk
53+
*.meta
54+
*.obj
55+
*.pch
56+
*.pdb
57+
*.pgc
58+
*.pgd
59+
*.rsp
60+
*.sbr
61+
*.tlb
62+
*.tli
63+
*.tlh
64+
*.tmp
65+
*.tmp_proj
66+
*.log
67+
*.vspscc
68+
*.vssscc
69+
.builds
70+
*.pidb
71+
*.svclog
72+
*.scc
73+
74+
# Chutzpah Test files
75+
_Chutzpah*
76+
77+
# Visual C++ cache files
78+
ipch/
79+
*.aps
80+
*.ncb
81+
*.opendb
82+
*.opensdf
83+
*.sdf
84+
*.cachefile
85+
86+
# Visual Studio profiler
87+
*.psess
88+
*.vsp
89+
*.vspx
90+
*.sap
91+
92+
# TFS 2012 Local Workspace
93+
$tf/
94+
95+
# Guidance Automation Toolkit
96+
*.gpState
97+
98+
# ReSharper is a .NET coding add-in
99+
_ReSharper*/
100+
*.[Rr]e[Ss]harper
101+
*.DotSettings.user
102+
103+
# JustCode is a .NET coding add-in
104+
.JustCode
105+
106+
# TeamCity is a build add-in
107+
_TeamCity*
108+
109+
# DotCover is a Code Coverage Tool
110+
*.dotCover
111+
112+
# NCrunch
113+
_NCrunch_*
114+
.*crunch*.local.xml
115+
nCrunchTemp_*
116+
117+
# MightyMoose
118+
*.mm.*
119+
AutoTest.Net/
120+
121+
# Web workbench (sass)
122+
.sass-cache/
123+
124+
# Installshield output folder
125+
[Ee]xpress/
126+
127+
# DocProject is a documentation generator add-in
128+
DocProject/buildhelp/
129+
DocProject/Help/*.HxT
130+
DocProject/Help/*.HxC
131+
DocProject/Help/*.hhc
132+
DocProject/Help/*.hhk
133+
DocProject/Help/*.hhp
134+
DocProject/Help/Html2
135+
DocProject/Help/html
136+
137+
# Click-Once directory
138+
publish/
139+
140+
# Publish Web Output
141+
*.[Pp]ublish.xml
142+
*.azurePubxml
143+
# TODO: Comment the next line if you want to checkin your web deploy settings
144+
# but database connection strings (with potential passwords) will be unencrypted
145+
*.pubxml
146+
*.publishproj
147+
148+
# NuGet Packages
149+
*.nupkg
150+
# The packages folder can be ignored because of Package Restore
151+
**/packages/*
152+
# except build/, which is used as an MSBuild target.
153+
!**/packages/build/
154+
# Uncomment if necessary however generally it will be regenerated when needed
155+
#!**/packages/repositories.config
156+
157+
# Microsoft Azure Build Output
158+
csx/
159+
*.build.csdef
160+
161+
# Microsoft Azure Emulator
162+
ecf/
163+
rcf/
164+
165+
# Microsoft Azure ApplicationInsights config file
166+
ApplicationInsights.config
167+
168+
# Windows Store app package directory
169+
AppPackages/
170+
BundleArtifacts/
171+
172+
# Visual Studio cache files
173+
# files ending in .cache can be ignored
174+
*.[Cc]ache
175+
# but keep track of directories ending in .cache
176+
!*.[Cc]ache/
177+
178+
# Others
179+
ClientBin/
180+
~$*
181+
*~
182+
*.dbmdl
183+
*.dbproj.schemaview
184+
*.pfx
185+
*.publishsettings
186+
node_modules/
187+
orleans.codegen.cs
188+
189+
# RIA/Silverlight projects
190+
Generated_Code/
191+
192+
# Backup & report files from converting an old project file
193+
# to a newer Visual Studio version. Backup files are not needed,
194+
# because we have git ;-)
195+
_UpgradeReport_Files/
196+
Backup*/
197+
UpgradeLog*.XML
198+
UpgradeLog*.htm
199+
200+
# SQL Server files
201+
*.mdf
202+
*.ldf
203+
204+
# Business Intelligence projects
205+
*.rdl.data
206+
*.bim.layout
207+
*.bim_*.settings
208+
209+
# Microsoft Fakes
210+
FakesAssemblies/
211+
212+
# GhostDoc plugin setting file
213+
*.GhostDoc.xml
214+
215+
# Node.js Tools for Visual Studio
216+
.ntvs_analysis.dat
217+
218+
# Visual Studio 6 build log
219+
*.plg
220+
221+
# Visual Studio 6 workspace options file
222+
*.opt
223+
224+
# Visual Studio LightSwitch build output
225+
**/*.HTMLClient/GeneratedArtifacts
226+
**/*.DesktopClient/GeneratedArtifacts
227+
**/*.DesktopClient/ModelManifest.xml
228+
**/*.Server/GeneratedArtifacts
229+
**/*.Server/ModelManifest.xml
230+
_Pvt_Extensions
231+
232+
# Paket dependency manager
233+
.paket/paket.exe
234+
235+
# FAKE - F# Make
236+
.fake/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using JsonApiDotNetCore.Controllers;
2+
using JsonApiDotNetCore.Services.Operations;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace OperationsExample.Controllers
6+
{
7+
[Route("api/[controller]")]
8+
public class OperationsController : JsonApiOperationsController
9+
{
10+
public OperationsController(IOperationsProcessor processor)
11+
: base(processor)
12+
{ }
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using OperationsExample.Models;
3+
4+
namespace OperationsExample.Data
5+
{
6+
public class AppDbContext : DbContext
7+
{
8+
public AppDbContext(DbContextOptions<AppDbContext> options)
9+
: base(options)
10+
{ }
11+
12+
public DbSet<Article> Articles { get; set; }
13+
}
14+
}

src/Examples/OperationsExample/Migrations/20170827234334_AddArticles.Designer.cs

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Microsoft.EntityFrameworkCore.Migrations;
4+
using Microsoft.EntityFrameworkCore.Metadata;
5+
6+
namespace OperationsExample.Migrations
7+
{
8+
public partial class AddArticles : Migration
9+
{
10+
protected override void Up(MigrationBuilder migrationBuilder)
11+
{
12+
migrationBuilder.CreateTable(
13+
name: "Articles",
14+
columns: table => new
15+
{
16+
Id = table.Column<int>(nullable: false)
17+
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
18+
Name = table.Column<string>(nullable: true)
19+
},
20+
constraints: table =>
21+
{
22+
table.PrimaryKey("PK_Articles", x => x.Id);
23+
});
24+
}
25+
26+
protected override void Down(MigrationBuilder migrationBuilder)
27+
{
28+
migrationBuilder.DropTable(
29+
name: "Articles");
30+
}
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Infrastructure;
4+
using Microsoft.EntityFrameworkCore.Metadata;
5+
using Microsoft.EntityFrameworkCore.Migrations;
6+
using OperationsExample.Data;
7+
8+
namespace OperationsExample.Migrations
9+
{
10+
[DbContext(typeof(AppDbContext))]
11+
partial class AppDbContextModelSnapshot : ModelSnapshot
12+
{
13+
protected override void BuildModel(ModelBuilder modelBuilder)
14+
{
15+
modelBuilder
16+
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
17+
.HasAnnotation("ProductVersion", "1.1.2");
18+
19+
modelBuilder.Entity("OperationsExample.Models.Article", b =>
20+
{
21+
b.Property<int>("Id")
22+
.ValueGeneratedOnAdd();
23+
24+
b.Property<string>("Name");
25+
26+
b.HasKey("Id");
27+
28+
b.ToTable("Articles");
29+
});
30+
}
31+
}
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using JsonApiDotNetCore.Models;
2+
3+
namespace OperationsExample.Models
4+
{
5+
public class Article : Identifiable
6+
{
7+
[Attr("name")]
8+
public string Name { get; set; }
9+
}
10+
}

0 commit comments

Comments
 (0)