Add boilerplate code without DB
This commit is contained in:
parent
6ff57add59
commit
ec91d04d0a
35 changed files with 1230 additions and 1 deletions
12
.config/dotnet-tools.json
Normal file
12
.config/dotnet-tools.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"csharpier": {
|
||||||
|
"version": "0.25.0",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-csharpier"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
477
.gitignore
vendored
Normal file
477
.gitignore
vendored
Normal file
|
@ -0,0 +1,477 @@
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# Tye
|
||||||
|
.tye/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
##
|
||||||
|
## Visual studio for Mac
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"dotnet.defaultSolution": "GitHubActionsDemo.sln"
|
||||||
|
}
|
41
GitHubActionsDemo.sln
Normal file
41
GitHubActionsDemo.sln
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.31903.59
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{53A44CCA-C5C6-4D98-91B8-D331D68BF7B0}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubActionsDemo.Api", "src\GitHubActionsDemo.Api\GitHubActionsDemo.Api.csproj", "{E3C34F79-B74E-44A4-99F0-B0B3C2D7CCB2}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubActionsDemo.Service", "src\GitHubActionsDemo.Service\GitHubActionsDemo.Service.csproj", "{F6807FFB-3C0D-4F84-8803-8ECAFD72EF76}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubActionsDemo.Persistance", "src\GitHubActionsDemo.Persistance\GitHubActionsDemo.Persistance.csproj", "{339301B3-E9BD-45D1-B6A9-94F41367DF16}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E3C34F79-B74E-44A4-99F0-B0B3C2D7CCB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E3C34F79-B74E-44A4-99F0-B0B3C2D7CCB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E3C34F79-B74E-44A4-99F0-B0B3C2D7CCB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E3C34F79-B74E-44A4-99F0-B0B3C2D7CCB2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F6807FFB-3C0D-4F84-8803-8ECAFD72EF76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F6807FFB-3C0D-4F84-8803-8ECAFD72EF76}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F6807FFB-3C0D-4F84-8803-8ECAFD72EF76}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F6807FFB-3C0D-4F84-8803-8ECAFD72EF76}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{339301B3-E9BD-45D1-B6A9-94F41367DF16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{339301B3-E9BD-45D1-B6A9-94F41367DF16}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{339301B3-E9BD-45D1-B6A9-94F41367DF16}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{339301B3-E9BD-45D1-B6A9-94F41367DF16}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{E3C34F79-B74E-44A4-99F0-B0B3C2D7CCB2} = {53A44CCA-C5C6-4D98-91B8-D331D68BF7B0}
|
||||||
|
{F6807FFB-3C0D-4F84-8803-8ECAFD72EF76} = {53A44CCA-C5C6-4D98-91B8-D331D68BF7B0}
|
||||||
|
{339301B3-E9BD-45D1-B6A9-94F41367DF16} = {53A44CCA-C5C6-4D98-91B8-D331D68BF7B0}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -1,2 +1,2 @@
|
||||||
# cicd-github-actions
|
# Setup a CI/CD Pipeline Using GitHub Actions
|
||||||
The code from my YouTube video on "Setup a CI/CD Pipeline Using GitHub Actions"
|
The code from my YouTube video on "Setup a CI/CD Pipeline Using GitHub Actions"
|
||||||
|
|
51
src/GitHubActionsDemo.Api/Controllers/LibraryController.cs
Normal file
51
src/GitHubActionsDemo.Api/Controllers/LibraryController.cs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
using GitHubActionsDemo.Api.Models;
|
||||||
|
using GitHubActionsDemo.Api.Mappers;
|
||||||
|
using GitHubActionsDemo.Service;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Api.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("[controller]")]
|
||||||
|
public class LibraryController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<LibraryController> _logger;
|
||||||
|
private readonly ILibraryService _libraryService;
|
||||||
|
|
||||||
|
public LibraryController(
|
||||||
|
ILogger<LibraryController> logger,
|
||||||
|
ILibraryService libraryService
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
_libraryService = libraryService ?? throw new ArgumentNullException(nameof(libraryService));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(Name = "GetBooks")]
|
||||||
|
public async Task<IEnumerable<BookResponse>> GetBooksAsync(int page = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
var books = await _libraryService.GetBooksAsync(page, pageSize);
|
||||||
|
return books.Select(x => x.Map());
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(Name = "GetBook")]
|
||||||
|
public async Task<BookResponse> GetBookAsync(int bookId)
|
||||||
|
{
|
||||||
|
var book = await _libraryService.GetBookAsync(bookId);
|
||||||
|
return book.Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost(Name = "AddBook")]
|
||||||
|
public async Task<BookResponse> AddBookAsync(BookRequest bookRequest)
|
||||||
|
{
|
||||||
|
var book = await _libraryService.AddBookAsync(bookRequest.Map());
|
||||||
|
return book.Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost(Name = "AddAuthor")]
|
||||||
|
public async Task<AuthorResponse> AddauthorAsync(AuthorRequest authorRequest)
|
||||||
|
{
|
||||||
|
var author = await _libraryService.AddAuthorAsync(authorRequest.Map());
|
||||||
|
return author.Map();
|
||||||
|
}
|
||||||
|
}
|
19
src/GitHubActionsDemo.Api/GitHubActionsDemo.Api.csproj
Normal file
19
src/GitHubActionsDemo.Api/GitHubActionsDemo.Api.csproj
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<RootNamespace>GitHubActionsDemo.Api</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GitHubActionsDemo.Service\GitHubActionsDemo.Service.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
26
src/GitHubActionsDemo.Api/Mappers/AuthorMapper.cs
Normal file
26
src/GitHubActionsDemo.Api/Mappers/AuthorMapper.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using GitHubActionsDemo.Api.Models;
|
||||||
|
using GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Api.Mappers;
|
||||||
|
|
||||||
|
public static class AuthorMapper
|
||||||
|
{
|
||||||
|
public static NewAuthor Map(this AuthorRequest request)
|
||||||
|
{
|
||||||
|
return new NewAuthor(
|
||||||
|
request.FirstName,
|
||||||
|
request.LastName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuthorResponse Map(this Author author)
|
||||||
|
{
|
||||||
|
return new AuthorResponse(
|
||||||
|
author.AuthorId,
|
||||||
|
author.FirstName,
|
||||||
|
author.LastName,
|
||||||
|
author.DateCreated,
|
||||||
|
author.DateModified
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
30
src/GitHubActionsDemo.Api/Mappers/BookMapper.cs
Normal file
30
src/GitHubActionsDemo.Api/Mappers/BookMapper.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using GitHubActionsDemo.Api.Models;
|
||||||
|
using GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Api.Mappers;
|
||||||
|
|
||||||
|
public static class BookMapper
|
||||||
|
{
|
||||||
|
public static NewBook Map(this BookRequest request)
|
||||||
|
{
|
||||||
|
return new NewBook(
|
||||||
|
request.Title,
|
||||||
|
request.AuthorId,
|
||||||
|
request.Isbn,
|
||||||
|
request.DatePublished
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BookResponse Map(this Book book)
|
||||||
|
{
|
||||||
|
return new BookResponse(
|
||||||
|
book.BookId,
|
||||||
|
book.Title,
|
||||||
|
book.Author.Map(),
|
||||||
|
book.Isbn,
|
||||||
|
book.DatePublished,
|
||||||
|
book.DateCreated,
|
||||||
|
book.DateModified
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
7
src/GitHubActionsDemo.Api/Models/AuthorRequest.cs
Normal file
7
src/GitHubActionsDemo.Api/Models/AuthorRequest.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace GitHubActionsDemo.Api.Models;
|
||||||
|
|
||||||
|
public class AuthorRequest
|
||||||
|
{
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
}
|
25
src/GitHubActionsDemo.Api/Models/AuthorResponse.cs
Normal file
25
src/GitHubActionsDemo.Api/Models/AuthorResponse.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
namespace GitHubActionsDemo.Api.Models;
|
||||||
|
|
||||||
|
public class AuthorResponse
|
||||||
|
{
|
||||||
|
public AuthorResponse(
|
||||||
|
int authorId,
|
||||||
|
string firstName,
|
||||||
|
string lastName,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AuthorId = authorId;
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AuthorId { get; }
|
||||||
|
public string FirstName { get; }
|
||||||
|
public string LastName { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
9
src/GitHubActionsDemo.Api/Models/BookRequest.cs
Normal file
9
src/GitHubActionsDemo.Api/Models/BookRequest.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace GitHubActionsDemo.Api.Models;
|
||||||
|
|
||||||
|
public class BookRequest
|
||||||
|
{
|
||||||
|
public string Title { get; set; }
|
||||||
|
public int AuthorId { get; set; }
|
||||||
|
public string Isbn { get; set; }
|
||||||
|
public DateOnly DatePublished { get; set; }
|
||||||
|
}
|
31
src/GitHubActionsDemo.Api/Models/BookResponse.cs
Normal file
31
src/GitHubActionsDemo.Api/Models/BookResponse.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
namespace GitHubActionsDemo.Api.Models;
|
||||||
|
|
||||||
|
public class BookResponse
|
||||||
|
{
|
||||||
|
public BookResponse(
|
||||||
|
int bookId,
|
||||||
|
string title,
|
||||||
|
AuthorResponse author,
|
||||||
|
string isbn,
|
||||||
|
DateOnly datePublished,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BookId = bookId;
|
||||||
|
Title = title;
|
||||||
|
Author = author;
|
||||||
|
Isbn = isbn;
|
||||||
|
DatePublished = datePublished;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BookId { get; }
|
||||||
|
public string Title { get; }
|
||||||
|
public AuthorResponse Author { get; }
|
||||||
|
public string Isbn { get; }
|
||||||
|
public DateOnly DatePublished { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
22
src/GitHubActionsDemo.Api/Program.cs
Normal file
22
src/GitHubActionsDemo.Api/Program.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using GitHubActionsDemo.Service;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
|
// DI
|
||||||
|
builder.Services.AddScoped<ILibraryService, LibraryService>();
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.MapControllers();
|
||||||
|
app.Run();
|
41
src/GitHubActionsDemo.Api/Properties/launchSettings.json
Normal file
41
src/GitHubActionsDemo.Api/Properties/launchSettings.json
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:41272",
|
||||||
|
"sslPort": 44315
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5275",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7025;http://localhost:5275",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
src/GitHubActionsDemo.Api/appsettings.Development.json
Normal file
8
src/GitHubActionsDemo.Api/appsettings.Development.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/GitHubActionsDemo.Api/appsettings.json
Normal file
9
src/GitHubActionsDemo.Api/appsettings.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
12
src/GitHubActionsDemo.Persistance/ILibraryRespository.cs
Normal file
12
src/GitHubActionsDemo.Persistance/ILibraryRespository.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
namespace GitHubActionsDemo.Persistance;
|
||||||
|
|
||||||
|
using GitHubActionsDemo.Persistance.Models;
|
||||||
|
|
||||||
|
public interface ILibraryRespository
|
||||||
|
{
|
||||||
|
Task<IEnumerable<BookDb>> GetBooksAsync(int page, int pageSize);
|
||||||
|
Task<BookDb> GetBookAsync(int bookId);
|
||||||
|
Task<BookDb> AddBookAsync(NewBookDb book);
|
||||||
|
Task<AuthorDb> AddAuthorAsync(NewAuthorDb author);
|
||||||
|
Task<AuthorDb> GetAuthorAsync(int authorId);
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
using GitHubActionsDemo.Persistance;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Service.Infrastructure
|
||||||
|
{
|
||||||
|
public static class InfrastructureExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddPersistanceDependencies(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
return services.AddSingleton<ILibraryRespository, LibraryRespository>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
src/GitHubActionsDemo.Persistance/LibraryRespository.cs
Normal file
36
src/GitHubActionsDemo.Persistance/LibraryRespository.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using GitHubActionsDemo.Persistance.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Persistance;
|
||||||
|
|
||||||
|
public class LibraryRespository : ILibraryRespository
|
||||||
|
{
|
||||||
|
public LibraryRespository()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthorDb> AddAuthorAsync(NewAuthorDb author)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthorDb> GetAuthorAsync(int authorId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<BookDb> AddBookAsync(NewBookDb book)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<BookDb> GetBookAsync(int bookId)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<BookDb>> GetBooksAsync(int page, int pageSize)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
25
src/GitHubActionsDemo.Persistance/Models/AuthorDb.cs
Normal file
25
src/GitHubActionsDemo.Persistance/Models/AuthorDb.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
namespace GitHubActionsDemo.Persistance.Models;
|
||||||
|
|
||||||
|
public class AuthorDb
|
||||||
|
{
|
||||||
|
public AuthorDb(
|
||||||
|
int authorId,
|
||||||
|
string firstName,
|
||||||
|
string lastName,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AuthorId = authorId;
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AuthorId { get; }
|
||||||
|
public string FirstName { get; }
|
||||||
|
public string LastName { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
31
src/GitHubActionsDemo.Persistance/Models/BookDb.cs
Normal file
31
src/GitHubActionsDemo.Persistance/Models/BookDb.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
namespace GitHubActionsDemo.Persistance.Models;
|
||||||
|
|
||||||
|
public class BookDb
|
||||||
|
{
|
||||||
|
public BookDb(
|
||||||
|
int bookId,
|
||||||
|
string title,
|
||||||
|
AuthorDb author,
|
||||||
|
string isbn,
|
||||||
|
DateOnly datePublished,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BookId = bookId;
|
||||||
|
Title = title;
|
||||||
|
Author = author;
|
||||||
|
Isbn = isbn;
|
||||||
|
DatePublished = datePublished;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BookId { get; }
|
||||||
|
public string Title { get; }
|
||||||
|
public AuthorDb Author { get; }
|
||||||
|
public string Isbn { get; }
|
||||||
|
public DateOnly DatePublished { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
22
src/GitHubActionsDemo.Persistance/Models/NewAuthorDb.cs
Normal file
22
src/GitHubActionsDemo.Persistance/Models/NewAuthorDb.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
namespace GitHubActionsDemo.Persistance.Models;
|
||||||
|
|
||||||
|
public class NewAuthorDb
|
||||||
|
{
|
||||||
|
public NewAuthorDb(
|
||||||
|
string firstName,
|
||||||
|
string lastName,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FirstName { get; }
|
||||||
|
public string LastName { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
29
src/GitHubActionsDemo.Persistance/Models/NewBookDb.cs
Normal file
29
src/GitHubActionsDemo.Persistance/Models/NewBookDb.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
namespace GitHubActionsDemo.Persistance.Models;
|
||||||
|
|
||||||
|
public class NewBookDb
|
||||||
|
{
|
||||||
|
public NewBookDb(
|
||||||
|
string title,
|
||||||
|
int authorId,
|
||||||
|
string isbn,
|
||||||
|
DateOnly datePublished,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
AuthorId = authorId;
|
||||||
|
Isbn = isbn;
|
||||||
|
DatePublished = datePublished;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BookId { get; }
|
||||||
|
public string Title { get; }
|
||||||
|
public int AuthorId { get; }
|
||||||
|
public string Isbn { get; }
|
||||||
|
public DateOnly DatePublished { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GitHubActionsDemo.Persistance\GitHubActionsDemo.Persistance.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
11
src/GitHubActionsDemo.Service/ILibraryService.cs
Normal file
11
src/GitHubActionsDemo.Service/ILibraryService.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Service;
|
||||||
|
|
||||||
|
public interface ILibraryService
|
||||||
|
{
|
||||||
|
Task<IEnumerable<Book>> GetBooksAsync(int page, int pageSize);
|
||||||
|
Task<Book> GetBookAsync(int bookId);
|
||||||
|
Task<Book> AddBookAsync(NewBook book);
|
||||||
|
Task<Author> AddAuthorAsync(NewAuthor author);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using GitHubActionsDemo.Persistance;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Service.Infrastructure
|
||||||
|
{
|
||||||
|
public static class InfrastructureExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddServiceDependencies(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
return services
|
||||||
|
.AddScoped<ILibraryService, LibraryService>()
|
||||||
|
.AddPersistanceDependencies();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
src/GitHubActionsDemo.Service/LibraryService.cs
Normal file
39
src/GitHubActionsDemo.Service/LibraryService.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using GitHubActionsDemo.Persistance;
|
||||||
|
using GitHubActionsDemo.Service.Mappers;
|
||||||
|
using GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Service;
|
||||||
|
|
||||||
|
public class LibraryService : ILibraryService
|
||||||
|
{
|
||||||
|
private readonly ILibraryRespository _libraryRepository;
|
||||||
|
|
||||||
|
public LibraryService(ILibraryRespository libraryRepository)
|
||||||
|
{
|
||||||
|
_libraryRepository = libraryRepository ?? throw new ArgumentNullException(nameof(libraryRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Author> AddAuthorAsync(NewAuthor newAuthor)
|
||||||
|
{
|
||||||
|
var author = await _libraryRepository.AddAuthorAsync(newAuthor.Map());
|
||||||
|
return author.Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Book> AddBookAsync(NewBook newBook)
|
||||||
|
{
|
||||||
|
var book = await _libraryRepository.AddBookAsync(newBook.Map());
|
||||||
|
return book.Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Book> GetBookAsync(int bookId)
|
||||||
|
{
|
||||||
|
var book = await _libraryRepository.GetBookAsync(bookId);
|
||||||
|
return book.Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Book>> GetBooksAsync(int page, int pageSize)
|
||||||
|
{
|
||||||
|
var books = await _libraryRepository.GetBooksAsync(page, pageSize);
|
||||||
|
return books.Select(book => book.Map());
|
||||||
|
}
|
||||||
|
}
|
29
src/GitHubActionsDemo.Service/Mappers/AuthorMapper.cs
Normal file
29
src/GitHubActionsDemo.Service/Mappers/AuthorMapper.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
using GitHubActionsDemo.Persistance.Models;
|
||||||
|
using GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Service.Mappers;
|
||||||
|
|
||||||
|
public static class AuthorMapper
|
||||||
|
{
|
||||||
|
public static NewAuthorDb Map(this NewAuthor author)
|
||||||
|
{
|
||||||
|
return new NewAuthorDb(
|
||||||
|
author.FirstName,
|
||||||
|
author.LastName,
|
||||||
|
DateTime.UtcNow,
|
||||||
|
DateTime.UtcNow
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Author Map(this AuthorDb author)
|
||||||
|
{
|
||||||
|
return new Author(
|
||||||
|
author.AuthorId,
|
||||||
|
author.FirstName,
|
||||||
|
author.LastName,
|
||||||
|
author.DateCreated,
|
||||||
|
author.DateModified
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
32
src/GitHubActionsDemo.Service/Mappers/BookMapper.cs
Normal file
32
src/GitHubActionsDemo.Service/Mappers/BookMapper.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using GitHubActionsDemo.Persistance.Models;
|
||||||
|
using GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
namespace GitHubActionsDemo.Service.Mappers;
|
||||||
|
|
||||||
|
public static class BookMapper
|
||||||
|
{
|
||||||
|
public static NewBookDb Map(this NewBook book)
|
||||||
|
{
|
||||||
|
return new NewBookDb(
|
||||||
|
book.Title,
|
||||||
|
book.AuthorId,
|
||||||
|
book.Isbn,
|
||||||
|
book.DatePublished,
|
||||||
|
DateTime.UtcNow,
|
||||||
|
DateTime.UtcNow
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Book Map(this BookDb book)
|
||||||
|
{
|
||||||
|
return new Book(
|
||||||
|
book.BookId,
|
||||||
|
book.Title,
|
||||||
|
book.Author.Map(),
|
||||||
|
book.Isbn,
|
||||||
|
book.DatePublished,
|
||||||
|
book.DateCreated,
|
||||||
|
book.DateModified
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
25
src/GitHubActionsDemo.Service/Models/Author.cs
Normal file
25
src/GitHubActionsDemo.Service/Models/Author.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
namespace GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
public class Author
|
||||||
|
{
|
||||||
|
public Author(
|
||||||
|
int authorId,
|
||||||
|
string firstName,
|
||||||
|
string lastName,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateUpdated
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AuthorId = authorId;
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AuthorId { get; }
|
||||||
|
public string FirstName { get; }
|
||||||
|
public string LastName { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
31
src/GitHubActionsDemo.Service/Models/Book.cs
Normal file
31
src/GitHubActionsDemo.Service/Models/Book.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
namespace GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
public class Book
|
||||||
|
{
|
||||||
|
public Book(
|
||||||
|
int bookId,
|
||||||
|
string title,
|
||||||
|
Author author,
|
||||||
|
string isbn,
|
||||||
|
DateOnly datePublished,
|
||||||
|
DateTime dateCreated,
|
||||||
|
DateTime dateModified
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BookId = bookId;
|
||||||
|
Title = title;
|
||||||
|
Author = author;
|
||||||
|
Isbn = isbn;
|
||||||
|
DatePublished = datePublished;
|
||||||
|
DateCreated = dateCreated;
|
||||||
|
DateModified = dateModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BookId { get; }
|
||||||
|
public string Title { get; }
|
||||||
|
public Author Author { get; }
|
||||||
|
public string Isbn { get; }
|
||||||
|
public DateOnly DatePublished { get; }
|
||||||
|
public DateTime DateCreated { get; }
|
||||||
|
public DateTime DateModified { get; }
|
||||||
|
}
|
16
src/GitHubActionsDemo.Service/Models/NewAuthor.cs
Normal file
16
src/GitHubActionsDemo.Service/Models/NewAuthor.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
namespace GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
public class NewAuthor
|
||||||
|
{
|
||||||
|
public NewAuthor(
|
||||||
|
string firstName,
|
||||||
|
string lastName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FirstName { get; }
|
||||||
|
public string LastName { get; }
|
||||||
|
}
|
22
src/GitHubActionsDemo.Service/Models/NewBook.cs
Normal file
22
src/GitHubActionsDemo.Service/Models/NewBook.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
namespace GitHubActionsDemo.Service.Models;
|
||||||
|
|
||||||
|
public class NewBook
|
||||||
|
{
|
||||||
|
public NewBook(
|
||||||
|
string title,
|
||||||
|
int authorId,
|
||||||
|
string isbn,
|
||||||
|
DateOnly datePublished
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
AuthorId = authorId;
|
||||||
|
Isbn = isbn;
|
||||||
|
DatePublished = datePublished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title { get; }
|
||||||
|
public int AuthorId { get; }
|
||||||
|
public string Isbn { get; }
|
||||||
|
public DateOnly DatePublished { get; }
|
||||||
|
}
|
Loading…
Reference in a new issue