Skip to content

Commit e787438

Browse files
committed
Initial
0 parents  commit e787438

13 files changed

+751
-0
lines changed

.gitignore

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
# .NET Core build folders
2+
bin/
3+
obj/
4+
5+
# Visual Studio files
6+
.vs/
7+
*.user
8+
*.userosscache
9+
*.sln.docstates
10+
11+
# Rider files
12+
.idea/
13+
14+
# User-specific files
15+
*.suo
16+
*.user
17+
*.userosscache
18+
*.sln.docstates
19+
20+
# Build results
21+
[Dd]ebug/
22+
[Dd]ebugPublic/
23+
[Rr]elease/
24+
[Rr]eleases/
25+
x64/
26+
x86/
27+
build/
28+
bld/
29+
[Bb]in/
30+
[Oo]bj/
31+
[Oo]ut/
32+
msbuild.log
33+
msbuild.err
34+
msbuild.wrn
35+
36+
# Visual Studio 2015/2017 cache/options directory
37+
.vs/
38+
39+
# Visual Studio 2017 auto generated files
40+
Generated\ Files/
41+
42+
# MSTest test Results
43+
[Tt]est[Rr]esult*/
44+
[Bb]uild[Ll]og.*
45+
46+
# NUNIT
47+
*.VisualState.xml
48+
TestResult.xml
49+
50+
# Build Results of an ATL Project
51+
[Dd]ebugPS/
52+
[Rr]eleasePS/
53+
dlldata.c
54+
55+
# .NET Core
56+
project.lock.json
57+
project.fragment.lock.json
58+
artifacts/
59+
60+
# Files built by Visual Studio
61+
*_i.c
62+
*_p.c
63+
*_h.h
64+
*.ilk
65+
*.meta
66+
*.obj
67+
*.iobj
68+
*.pch
69+
*.pdb
70+
*.ipdb
71+
*.pgc
72+
*.pgd
73+
*.rsp
74+
*.sbr
75+
*.tlb
76+
*.tli
77+
*.tlh
78+
*.tmp
79+
*.tmp_proj
80+
*_wpftmp.csproj
81+
*.log
82+
*.vspscc
83+
*.vssscc
84+
.builds
85+
*.pidb
86+
*.svclog
87+
*.scc
88+
89+
# Visual Studio profiler
90+
*.psess
91+
*.vsp
92+
*.vspx
93+
*.sap
94+
95+
# Visual Studio Trace Files
96+
*.e2e
97+
98+
# ReSharper is a .NET coding add-in
99+
_ReSharper*/
100+
*.[Rr]e[Ss]harper
101+
*.DotSettings.user
102+
103+
# Visual Studio code coverage results
104+
*.coverage
105+
*.coveragexml
106+
107+
# NuGet Packages
108+
*.nupkg
109+
# NuGet Symbol Packages
110+
*.snupkg
111+
# The packages folder can be ignored because of Package Restore
112+
**/[Pp]ackages/*
113+
# except build/, which is used as an MSBuild target.
114+
!**/[Pp]ackages/build/
115+
# Uncomment if necessary however generally it will be regenerated when needed
116+
#!**/[Pp]ackages/repositories.config
117+
# NuGet v3's project.json files produces more ignorable files
118+
*.nuget.props
119+
*.nuget.targets
120+
121+
# Microsoft Azure Build Output
122+
csx/
123+
*.build.csdef
124+
125+
# Microsoft Azure Emulator
126+
ecf/
127+
rcf/
128+
129+
# Windows Store app package directories and files
130+
AppPackages/
131+
BundleArtifacts/
132+
Package.StoreAssociation.xml
133+
_pkginfo.txt
134+
*.appx
135+
*.appxbundle
136+
*.appxupload
137+
138+
# Visual Studio cache files
139+
# files ending in .cache can be ignored
140+
*.[Cc]ache
141+
# but keep track of directories ending in .cache
142+
!?*.[Cc]ache/
143+
144+
# Others
145+
ClientBin/
146+
~$*
147+
*~
148+
*.dbmdl
149+
*.dbproj.schemaview
150+
*.jfm
151+
*.pfx
152+
*.publishsettings
153+
orleans.codegen.cs
154+
155+
# SQL Server files
156+
*.mdf
157+
*.ldf
158+
*.ndf
159+
160+
# Business Intelligence projects
161+
*.rdl.data
162+
*.bim.layout
163+
*.bim_*.settings
164+
*.rptproj.rsuser
165+
*- [Bb]ackup.rdl
166+
*- [Bb]ackup ([0-9]).rdl
167+
*- [Bb]ackup ([0-9][0-9]).rdl
168+
169+
# Microsoft Fakes
170+
FakesAssemblies/
171+
172+
# Node.js Tools for Visual Studio
173+
.ntvs_analysis.dat
174+
node_modules/
175+
176+
# Visual Studio 6 build log
177+
*.plg
178+
179+
# Visual Studio 6 workspace options file
180+
*.opt
181+
182+
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
183+
*.vbw
184+
185+
# Visual Studio LightSwitch build output
186+
**/*.HTMLClient/GeneratedArtifacts
187+
**/*.DesktopClient/GeneratedArtifacts
188+
**/*.DesktopClient/ModelManifest.xml
189+
**/*.Server/GeneratedArtifacts
190+
**/*.Server/ModelManifest.xml
191+
_Pvt_Extensions
192+
193+
# Paket dependency manager
194+
.paket/paket.exe
195+
paket-files/
196+
197+
# FAKE - F# Make
198+
.fake/
199+
200+
# CodeRush personal settings
201+
.cr/personal
202+
203+
# Python Tools for Visual Studio (PTVS)
204+
__pycache__/
205+
*.pyc
206+
207+
# Cake - Uncomment if you are using it
208+
# tools/**
209+
# !tools/packages.config
210+
211+
# Tabs Studio
212+
*.tss
213+
214+
# Telerik's JustMock configuration file
215+
*.jmconfig
216+
217+
# BizTalk build output
218+
*.btp.cs
219+
*.btm.cs
220+
*.odx.cs
221+
*.xsd.cs
222+
223+
# OpenCover UI analysis results
224+
OpenCover/
225+
226+
# Azure Stream Analytics local run output
227+
ASALocalRun/
228+
229+
# MSBuild Binary and Structured Log
230+
*.binlog
231+
232+
# NVidia Nsight GPU debugger configuration file
233+
*.nvuser
234+
235+
# MFractors (Xamarin productivity tool) working folder
236+
.mfractor/
237+
238+
# Local History for Visual Studio
239+
.localhistory/
240+
241+
# BeatPulse healthcheck temp database
242+
healthchecksdb
243+
244+
# Backup folder for Package Reference Convert tool in Visual Studio 2017
245+
MigrationBackup/
246+
247+
# Ionide (cross platform F# VS Code tools) working folder
248+
.ionide/
249+
250+
# Fody - auto-generated XML schema
251+
FodyWeavers.xsd
252+
253+
# VS Code files for those working on multiple tools
254+
.vscode/*
255+
!.vscode/settings.json
256+
!.vscode/tasks.json
257+
!.vscode/launch.json
258+
!.vscode/extensions.json
259+
*.code-workspace
260+
261+
# Local History for Visual Studio Code
262+
.history/
263+
264+
# Windows Installer files from build outputs
265+
*.cab
266+
*.msi
267+
*.msix
268+
*.msm
269+
*.msp
270+
271+
# JetBrains Rider
272+
.idea/
273+
*.sln.iml
274+
275+
# macOS
276+
.DS_Store
277+
278+
# Windows thumbnail cache files
279+
Thumbs.db
280+
Thumbs.db:encryptable
281+
ehthumbs.db
282+
ehthumbs_vista.db
283+
284+
# Dump file
285+
*.stackdump
286+
287+
# Folder config file
288+
[Dd]esktop.ini
289+
290+
# Recycle Bin used on file shares
291+
$RECYCLE.BIN/
292+
293+
# Windows Installer files
294+
*.cab
295+
*.msi
296+
*.msix
297+
*.msm
298+
*.msp
299+
300+
# Windows shortcuts
301+
*.lnk

Controllers/BooksController.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.EntityFrameworkCore;
3+
4+
[ApiController]
5+
[Route("api/[controller]")]
6+
public class BooksController : ControllerBase
7+
{
8+
private readonly AppDbContext _context;
9+
10+
public BooksController(AppDbContext context)
11+
{
12+
_context = context;
13+
}
14+
15+
[HttpGet]
16+
public async Task<ActionResult<IEnumerable<Book>>> GetBooks()
17+
{
18+
return await _context.Books.ToListAsync();
19+
}
20+
}

Data/AppDbContext.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Microsoft.EntityFrameworkCore;
2+
3+
public class AppDbContext : DbContext
4+
{
5+
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
6+
7+
public DbSet<Book> Books { get; set; }
8+
9+
protected override void OnModelCreating(ModelBuilder modelBuilder)
10+
{
11+
// Seed data
12+
modelBuilder.Entity<Book>().HasData(
13+
new Book { Id = 1, Title = "1984", Author = "George Orwell", PublicationYear = 1949 },
14+
new Book { Id = 2, Title = "To Kill a Mockingbird", Author = "Harper Lee", PublicationYear = 1960 },
15+
new Book { Id = 3, Title = "The Great Gatsby", Author = "F. Scott Fitzgerald", PublicationYear = 1925 }
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)