Try Push
continuous-integration/drone/push Build encountered an error Details

master
dorian.hodin 2 years ago
commit c514f69be6

@ -0,0 +1,93 @@
kind: pipeline
type: docker
name: myFirstPipeline
trigger:
event:
- push
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:7.0
commands:
- cd Sources
- dotnet restore OpenLibraryWS_Wrapper.sln
- dotnet build OpenLibraryWS_Wrapper.sln -c Release --no-restore
- dotnet publish OpenLibraryWS_Wrapper.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release
- name: tests
image: mcr.microsoft.com/dotnet/sdk:7.0
commands:
- cd Sources/
- dotnet restore OpenLibraryWS_Wrapper.sln
- dotnet test OpenLibraryWS_Wrapper.sln --no-restore
depends_on: [build]
- name: generate-and-deploy-docs
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
failure: ignore
volumes:
- name: docs
path: /docs
commands:
- /entrypoint.sh
when:
branch:
- master
event:
- push
- pull_request
depends_on: [build,tests]
- name: generate-swashbuckle
image: mcr.microsoft.com/dotnet/sdk:7.0
commands:
- cd Sources/OpenLibraryWrapper
- dotnet tool install --version 6.5.0 Swashbuckle.AspNetCore.Cli --tool-path /bin
- /bin/swagger tofile --output /drone/src/swagger.json bin/Release/net7.0/OpenLibraryWrapper.dll v1
depends_on: [build]
- name: deploy-swagger
image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer
commands:
- /entrypoint.sh --type swagger --loc /drone/src/swagger.json
depends_on: [generate-swashbuckle]
# - name: hadolint
# image: hadolint/hadolint:latest-debian
# commands:
# - cd Sources
# - hadolint -i DL3059 Dockerfile
- name: docker-build-and-push
image: plugins/docker
settings:
dockerfile: Sources/Dockerfile
context: Sources/
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/dorian.hodin/tmp
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
depends_on: [build,tests]
- name: deploy-container-mariadb
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: mariadb:10
CONTAINERNAME: mathiery-db
COMMAND: create
OVERWRITE: true
PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD:
from_secret: db_root_password
CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE:
from_secret: db_database
CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER:
from_secret: db_user
CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD:
from_secret: db_password
depends_on: [deploy-container]

428
.gitignore vendored

@ -0,0 +1,428 @@
# ---> macOS
# 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
# ---> VisualStudio
## 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 Core
project.lock.json
project.fragment.lock.json
artifacts/
# 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

@ -0,0 +1,444 @@
# Doxyfile 1.9.1
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a double hash (##) is considered a comment and is placed in
# front of the TAG it is preceding.
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
# TAG = value [value, ...]
# For lists, items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (\" \").
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "OpenLibraryWS_Wrapper-Marc-THIERY"
PROJECT_NUMBER = 1.0.0
PROJECT_BRIEF = "My super project"
PROJECT_LOGO = images/mylogo.png
OUTPUT_DIRECTORY = /docs/doxygen
CREATE_SUBDIRS = NO
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
JAVADOC_BANNER = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
PYTHON_DOCSTRING = YES
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 4
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
# Well... the one for Java looks so similar to the one for C#...
OPTIMIZE_OUTPUT_JAVA = YES
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
OPTIMIZE_OUTPUT_SLICE = NO
EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
TOC_INCLUDE_HEADINGS = 5
AUTOLINK_SUPPORT = YES
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
GROUP_NESTED_COMPOUNDS = NO
SUBGROUPING = YES
INLINE_GROUPED_CLASSES = NO
INLINE_SIMPLE_STRUCTS = NO
TYPEDEF_HIDES_STRUCT = NO
LOOKUP_CACHE_SIZE = 0
NUM_PROC_THREADS = 1
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
# I do not like other members to see my private members... but you can set it to YES if you prefer.
EXTRACT_PRIVATE = NO
EXTRACT_PRIV_VIRTUAL = NO
EXTRACT_PACKAGE = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
RESOLVE_UNNAMED_PARAMS = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
HIDE_COMPOUND_REFERENCE= NO
SHOW_HEADERFILE = YES
SHOW_INCLUDE_FILES = YES
SHOW_GROUPED_MEMB_INC = NO
FORCE_LOCAL_INCLUDES = NO
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_MEMBERS_CTORS_1ST = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
LAYOUT_FILE =
CITE_BIB_FILES =
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_IF_INCOMPLETE_DOC = YES
WARN_NO_PARAMDOC = NO
WARN_AS_ERROR = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../../Sources
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.idl \
*.ddl \
*.odl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.l \
*.cs \
*.d \
*.php \
*.php4 \
*.php5 \
*.phtml \
*.inc \
*.m \
*.markdown \
*.md \
*.mm \
*.dox \
*.py \
*.pyw \
*.f90 \
*.f95 \
*.f03 \
*.f08 \
*.f18 \
*.f \
*.for \
*.vhd \
*.vhdl \
*.ucf \
*.qsf \
*.ice
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = */Tests/*
EXCLUDE_PATTERNS += */bin/*
EXCLUDE_PATTERNS += */obj/*
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
FILTER_SOURCE_PATTERNS =
USE_MDFILE_AS_MAINPAGE =
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
CLANG_ASSISTED_PARSING = NO
CLANG_ADD_INC_PATHS = YES
CLANG_OPTIONS =
CLANG_DATABASE_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER = footer.html
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES = images/CodeFirst.png images/clubinfo.png
HTML_COLORSTYLE_HUE = 215
HTML_COLORSTYLE_SAT = 45
HTML_COLORSTYLE_GAMMA = 240
HTML_TIMESTAMP = NO
HTML_DYNAMIC_MENUS = YES
HTML_DYNAMIC_SECTIONS = NO
HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_FEEDURL =
DOCSET_BUNDLE_ID = org.doxygen.Project
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
DOCSET_PUBLISHER_NAME = Publisher
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
GENERATE_QHP = NO
QCH_FILE =
QHP_NAMESPACE = org.doxygen.Project
QHP_VIRTUAL_FOLDER = doc
QHP_CUST_FILTER_NAME =
QHP_CUST_FILTER_ATTRS =
QHP_SECT_FILTER_ATTRS =
QHG_LOCATION =
GENERATE_ECLIPSEHELP = NO
ECLIPSE_DOC_ID = org.doxygen.Project
DISABLE_INDEX = NO
GENERATE_TREEVIEW = NO
FULL_SIDEBAR = NO
ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
EXT_LINKS_IN_WINDOW = NO
OBFUSCATE_EMAILS = YES
HTML_FORMULA_FORMAT = png
FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
FORMULA_MACROFILE =
USE_MATHJAX = NO
MATHJAX_VERSION = MathJax_2
MATHJAX_FORMAT = HTML-CSS
MATHJAX_RELPATH =
MATHJAX_EXTENSIONS =
MATHJAX_CODEFILE =
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO
SEARCHENGINE_URL =
SEARCHDATA_FILE = searchdata.xml
EXTERNAL_SEARCH_ID =
EXTRA_SEARCH_MAPPINGS =
#---------------------------------------------------------------------------
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME =
MAKEINDEX_CMD_NAME = makeindex
LATEX_MAKEINDEX_CMD = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4
EXTRA_PACKAGES =
LATEX_HEADER =
LATEX_FOOTER =
LATEX_EXTRA_STYLESHEET =
LATEX_EXTRA_FILES =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
LATEX_BIB_STYLE = plain
LATEX_TIMESTAMP = NO
LATEX_EMOJI_DIRECTORY =
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# Configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_SUBDIR =
MAN_LINKS = NO
#---------------------------------------------------------------------------
# Configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_PROGRAMLISTING = YES
XML_NS_MEMB_FILE_SCOPE = NO
#---------------------------------------------------------------------------
# Configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
GENERATE_DOCBOOK = NO
DOCBOOK_OUTPUT = docbook
#---------------------------------------------------------------------------
# Configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to Sqlite3 output
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration options related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
DIA_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
DOT_NUM_THREADS = 0
DOT_FONTNAME = Helvetica
DOT_FONTSIZE = 10
DOT_FONTPATH =
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
UML_LIMIT_NUM_FIELDS = 10
DOT_UML_DETAILS = NO
DOT_WRAP_THRESHOLD = 17
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DIR_GRAPH_MAX_DEPTH = 1
DOT_IMAGE_FORMAT = png
INTERACTIVE_SVG = NO
DOT_PATH =
DOTFILE_DIRS =
MSCFILE_DIRS =
DIAFILE_DIRS =
PLANTUML_JAR_PATH =
PLANTUML_CFG_FILE =
PLANTUML_INCLUDE_PATH =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES

@ -0,0 +1,9 @@
<div id="test">
test
</div>
<div id="test2">
test2
</div>
<img src="https://imgs.search.brave.com/CX4uQ844WBbE6XdNosFGeoL93oGMKlS_We1K90RlQRI/rs:fit:860:0:0/g:ce/aHR0cHM6Ly9zdC5k/ZXBvc2l0cGhvdG9z/LmNvbS8xMDY0MDI0/LzM4NzcvaS82MDAv/ZGVwb3NpdHBob3Rv/c18zODc3MzM0OS1z/dG9jay1waG90by1w/bGFuZXQtZWFydGgt/YW5kLXN1bi5qcGc" alt="alternatetext">

@ -0,0 +1,237 @@
# OpenLibraryWS_wrapper
## Summary
This project proposes a Web Service wrapping the [OpenLibrary](https://openlibrary.org/). This is an archive of books and editions and it proposes a web api. This work here is a wrapper in order to simplify the use of this api, with less routes, and also to be interchangeable with another web service that will be issued shortly, owning its proper database of books.
Its purpose is mainly and only to be used by my students in order to practice a little bit _continuous integration_ and _continuous deployment_.
## Table of Contents
[Documentation](#documentation)
[Getting Started](#getting-started)
[Where are we now?](#where-are-we-now)
[Usage](#usage)
[Running the tests](#running-the-tests)
[Known issues and limitations](#known-issues-and-limitations)
[Built with](#built-with)
[Authors](#authors)
[Acknowledgements](#acknowledgements)
## Documentation
There is no other documentation than this ```ReadMe```, at least for now.
But here are some useful informations.
### Package diagram
```mermaid
flowchart LR
DTOAbstractLayer -.-> LibraryDTO
JSonReader -.-> LibraryDTO
OpenLibraryClient -.-> DTOAbstractLayer
OpenLibraryClient -.-> JSonReader
StubbedDTO -.-> DTOAbstractLayer
StubbedDTO -.-> JSonReader
OpenLibraryWrapper -.-> OpenLibraryClient
OpenLibraryWrapper -.-> StubbedDTO
```
This work contains some projects:
- ```LibraryDTO```: contains all **DTO** (_Data Transfer Object_) used by the web service(s) of this project
- ```DTOAbstractLayer```: defines a unique interface (```IDtoManager```) for all objects that can be used to make requests
- ```JSonReader```: contains some tools simplifying the parsing of json request results coming from ```OpenLibrary API```
- ```StubbedDTO```: is only used for testing the preceding packages. It contains some json files copied from ```OpenLibrary API``` request results
- ```OpenLibraryClient```: this is the wrapper of ```OpenLibrary API```. It implements ```IDtoManager``` and uses ```OpenLibrary API``` requests to get books and authors.
- ```OpenLibraryWrapper```: defines our Web Service and its routes.
### Routes of ```OpenLibraryWrapper``` web service:
There are very few routes:
- **get books by title**: allows to get books containing a particular string in their titles.
```
book/getbooksbytitle?title=ne&index=0&count=5
book/getbooksbytitle?title=ne&index=0&count=5&sort=old
```
- **get books by author**: allows to get books containing a particular string in the author names or alternate names.
```
book/getbooksbyauthor?name=al&index=0&count=5
book/getbooksbyauthor?name=al&index=0&count=5&sort=old
```
- **get books by author id**: allows to get books of a particular author by giving its id.
```
book/getbooksbyauthorid?id=OL1846639A&index=0&count=5
book/getbooksbyauthorid?id=OL1846639A&index=0&count=5&sort=old
```
- **get authors by name**: allows to get authors whose name (or alternate names) contains a particular string.
```
book/getauthorsbyname?name=al&index=0&count=5
book/getauthorsbyname?name=al&index=0&count=5&sort=name
```
- **get book by isbn**: allows to get a book by giving its isbn.
```
book/getBookByIsbn/9782330033118
```
- **get book by id**: allows to get a book by giving its id.
```
book/getBookById/OL25910297M
```
- **get author by id**: allows to get an author by giving its id.
```
book/getAuthorById/OL1846639A
```
### Class diagram
For what it's worth...
You will probably not need it...
Nevertheless, it shows how **DTO** classes are working with each other.
```mermaid
classDiagram
direction LR
class BookDTO {
+Id : string
+Title : string
+Publishers : List~string~
+PublishDate : DateTime
+ISBN13 : string
+Series : List~string~
+NbPages : int
+Format : string
+ImageSmall : string
+ImageMedium : string
+ImageLarge : string
}
class Languages {
<<enum>>
Unknown,
French,
}
class WorkDTO {
+Id : string
+Description : string
+Title : string
+Subjects : List~string~
}
class ContributorDTO {
+Name : string
+Role : string
}
class AuthorDTO {
+Id : string
+Name : string
+ImageSmall : string
+ImageMedium : string
+ImageLarge : string
+Bio : string
+AlternateNames : List~string~
+BirthDate : DateTime?
+DeathDate : DateTime?
}
class LinkDTO {
+Title : string
+Url : string
}
class RatingsDTO {
+Average : float
+Count : int
}
BookDTO --> "1" Languages : Language
BookDTO --> "*" ContributorDTO : Contributors
AuthorDTO --> "*" LinkDTO : Links
WorkDTO --> "*" AuthorDTO : Authors
WorkDTO --> "1" RatingsDTO : Ratings
BookDTO --> "*" AuthorDTO : Authors
BookDTO --> "*" WorkDTO : Works
```
## Getting Started
If you want to test this project locally, simply ```git clone``` this project, and open the solution ```Sources/OpenLibraryWS_Wrapper.sln```.
### Prerequisites
- Visual Studio 2019 or Visual Studio for Mac
- .NET 7.0 or higher
### Setup
Just ```git clone``` and build the solution.
## Where are we now?
Well, some parts are missing for pedagogical purposes...
- There is no CI/CD file. You will have to prepare it all by yourself.
- There is no files allowing to generate documentation (doxygen documentation for the code or swagger for the web api routes)
- There is no ```Dockerfile```.
Moreover, a lot of stuff could be enhanced, but I do not have time for this:
- there are too few unit tests
- there are too few comments in code
- the second version of the web service with its own database is not ready yet (but soon hopefully).
## Running the tests
You can run some unit tests but there are few. The unit tests project is ```OpenLibraryWrapper_UT```.
Run them in Visual Studio or using the command ```dotnet test```.
## Known issues and limitations
- CI/CD is not set yet.
- Documentation is not deployed.
## Built with
.NET and Visual Studio for Mac
## Next steps
This project should be enhanced with _Continuous Integration_ and _Continuous Deployment_ pipelines.
Here are the different steps that should be added:
1. **build** job:
All the projects of the solution should be built and published.
In order to write this job, one could find useful information in:
- the [**code first documentation about CI build jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/CI/build/)
- the [**dotnet official documentation**](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet) about .NET command lines.
To build and publish a .NET solution, you usually need to ```restore```, ```build``` and ```publish```.
2. **unit tests** job:
All the unit tests projects of the solution should be run.
In order to write this job, one could find useful information in:
- the [**code first documentation about CI unit tests jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/CI/tests/)
- the [**dotnet official documentation**](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet) about .NET command lines.
To run .NET unit tests projects, you usually need to ```restore``` and ```test```.
3. **continuous integration** job:
A code analysis should be run and exported to **Sonarqube**.
One can find useful information in:
- the [**code first documentation about CI unit tests jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/CI/codeInspection/)
- the [**SonarQube documentation**](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner-for-dotnet/) for .NET
4. **documentation** jobs:
Two different documentations should be published:
- **doxygen**: although very few comments are present in the source code, a doxygen documentation should be deployed.
It could look like this:
<img src="screens/doxygen1.png" width="300px"/>
And the footer could look like this:
<img src="screens/doxygen2.png" width="300px"/>
One could find useful information in:
- the [**code first documentation about doxygen jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/DocJobs/doxygen/)
- the [**official doxygen documentation**](https://www.doxygen.nl/)
- **swagger**: the routes of the web service should be documented through a Swagger documentation. But nothing has been prepared in Web Service project. First, one should modify the .NET project to add Swagger documentation generation, and next modify the documentation job.
It could look like this:
<img src="screens/swagger.png" width="300px"/>
And the footer could look like this:
One could find useful information in:
- the [**documentation about how to integrate Swagger in a .NET project**](https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-7.0&tabs=visual-studio).
- the [**documentation of Swashbuckle.AspNetCore**](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) and especially the **Cli** part.
5. **building the web api docker image** job:
The Dockerfile has not been prepared. Its entry point should be ```ENTRYPOINT ["dotnet", "OpenLibraryWrapper.dll"]```.
6. **deploying containers using the web api**:
The Web api is dependent on a service represented by the interface ```IDtoManager```. Three versions of this service have been prepared:
- the stub (injected by default),
- the wrapping of the OpenLibrary web api,
- the use of a database (see next section).
You should allow the deployment of the previous web api image but with different dependency injections. The choice should be made by entering a particular environment variable in the job. This variable should then be read in the C# code of the web api in order to inject the corresponding service.
7. **deploying the database and the web api consuming it**:
The third versions of the web api container should consume the database. This one should first be deployed. Then, modify the web api source to retrieve the connexion string and connect your web api container to the database.
## Authors
Marc Chevaldonné
## Acknowledgements
Camille Petitalot and Cédric Bouhours

@ -0,0 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 as build-env
WORKDIR /Sources
COPY . .
RUN dotnet restore /Sources/OpenLibraryWrapper/OpenLibraryWrapper.csproj
RUN dotnet publish -c Release -o /publish
FROM mcr.microsoft.com/dotnet/aspnet:7.0 as runtime
WORKDIR /publish
COPY --from=build-env /publish .
EXPOSE 80
ENTRYPOINT ["dotnet", "OpenLibraryWrapper.dll"]

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,97 @@
using LibraryDTO;
namespace DtoAbstractLayer;
/// <summary>
/// abstract layer for requests on Books Library
/// </summary>
public interface IDtoManager
{
/// <summary>
/// get a book by specifying its id
/// </summary>
/// <param name="id">id of the Book to get</param>
/// <returns>a Book with this id (or null if id is unknown)</returns>
Task<BookDTO> GetBookById(string id);
/// <summary>
/// get a book by specifying its isbn
/// </summary>
/// <param name="isbn">isbn of the Book to get</param>
/// <returns>a Book with this isbn (or null if isbn is unknown)</returns>
Task<BookDTO> GetBookByISBN(string isbn);
/// <summary>
/// get books containing a substring in their titles
/// </summary>
/// <param name="title">the substring to look for in book titles</param>
/// <param name="index">index of the page of resulting books</param>
/// <param name="count">number of resulting books per page</param>
/// <param name="sort">sort criterium (not mandatory):
/// <ul>
/// <li>```title```: sort books by titles in alphabetical order,</li>
/// <li>```title_reverse```: sort books by titles in reverse alphabetical order,</li>
/// <li>```new```: sort books by publishing dates, beginning with the most recents,</li>
/// <li>```old```: sort books by publishing dates, beginning with the oldest</li>
/// </ul>
/// </param>
/// <returns>max <i>count</i> books</returns>
Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByTitle(string title, int index, int count, string sort = "");
/// <summary>
/// get books of a particular author by giving the author id
/// </summary>
/// <param name="authorId">the id of the author</param>
/// <param name="index">index of the page of resulting books</param>
/// <param name="count">number of resulting books per page</param>
/// <param name="sort">sort criterium (not mandatory):
/// <ul>
/// <li>```title```: sort books by titles in alphabetical order,</li>
/// <li>```title_reverse```: sort books by titles in reverse alphabetical order,</li>
/// <li>```new```: sort books by publishing dates, beginning with the most recents,</li>
/// <li>```old```: sort books by publishing dates, beginning with the oldest</li>
/// </ul>
/// </param>
/// <returns>max <i>count</i> books</returns>
Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "");
/// <summary>
/// get books of authors whose name (or alternate names) contains a particular substring
/// </summary>
/// <param name="author">name to look for in author names or alternate names</param>
/// <param name="index">index of the page of resulting books</param>
/// <param name="count">number of resulting books per page</param>
/// <param name="sort">sort criterium (not mandatory):
/// <ul>
/// <li>```title```: sort books by titles in alphabetical order,</li>
/// <li>```title_reverse```: sort books by titles in reverse alphabetical order,</li>
/// <li>```new```: sort books by publishing dates, beginning with the most recents,</li>
/// <li>```old```: sort books by publishing dates, beginning with the oldest</li>
/// </ul>
/// </param>
/// <returns>max <i>count</i> books</returns>
Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthor(string author, int index, int count, string sort = "");
/// <summary>
/// get an author by specifying its id
/// </summary>
/// <param name="id">id of the Author to get</param>
/// <returns>an author with this id (or null if id is unknown)</returns>
Task<AuthorDTO> GetAuthorById(string id);
/// <summary>
/// get authors containing a substring in their names (or alternate names)
/// </summary>
/// <param name="substring">the substring to look for in author names (or alternate names)</param>
/// <param name="index">index of the page of resulting authors</param>
/// <param name="count">number of resulting authors per page</param>
/// <param name="sort">sort criterium (not mandatory):
/// <ul>
/// <li>```name```: sort authors by names in alphabetical order,</li>
/// <li>```name_reverse```: sort authors by names in reverse alphabetical order,</li>
/// </ul>
/// </param>
/// <returns>max <i>count</i> authors</returns>
Task<Tuple<long, IEnumerable<AuthorDTO>>> GetAuthorsByName(string substring, int index, int count, string sort = "");
}

@ -0,0 +1,80 @@
using System;
using LibraryDTO;
using Newtonsoft.Json.Linq;
using System.Globalization;
namespace JsonReader
{
public static class AuthorJsonReader
{
public static AuthorDTO ReadAuthor(string json)
{
JObject o = JObject.Parse(json);
string bioTokenAsString = null;
if(o.TryGetValue("bio", out JToken? bioToken))
{
if(bioToken.Type == JTokenType.String)
{
bioTokenAsString = (string)bioToken;
}
else
{
var bioTokenValue = o["bio"]?["value"];
bioTokenAsString = (string)bioTokenValue;
}
}
AuthorDTO author = new AuthorDTO
{
Id = (string)o["key"],
Name = (string)o["name"],
Bio = bioTokenAsString,
BirthDate = o.TryGetValue("birth_date", out JToken? bd) ? ReadDate((string)o["birth_date"]) : null,
DeathDate = o.TryGetValue("death_date", out JToken? dd) ? ReadDate((string)o["death_date"]) : null,
Links = o.TryGetValue("links", out JToken? links) ? links.Select(l => new LinkDTO { Title = (string)l["title"], Url = (string)l["url"] }).ToList() : new List<LinkDTO>(),
AlternateNames = o.TryGetValue("alternate_names", out JToken? altNames) ? altNames.Select(alt => (string)alt).ToList() : new List<string?>()
};
return author;
}
public static DateTime? ReadDate(string dateInJson)
{
if(dateInJson == null) return null;
List<Tuple<string, CultureInfo>> pubDateFormat =new List<Tuple<string, CultureInfo>>()
{
Tuple.Create("d MMMM yyyy", CultureInfo.GetCultureInfo("fr-FR")),
Tuple.Create("d MMMM yyyy", CultureInfo.InvariantCulture),
Tuple.Create("MMM dd, yyyy", CultureInfo.InvariantCulture)
};
DateTime? publishDate = null;
foreach(var format in pubDateFormat)
{
if(DateTime.TryParseExact(dateInJson, format.Item1, format.Item2, DateTimeStyles.None, out DateTime readDate))
{
publishDate = readDate;
break;
}
}
if(!publishDate.HasValue && int.TryParse(dateInJson, out int year))
{
publishDate = new DateTime(year, 12, 31);
}
return publishDate;
}
public static Tuple<long, IEnumerable<AuthorDTO>> GetAuthorsByName(string json)
{
JObject o = JObject.Parse(json);
long numFound = (long)o["numFound"];
var authors = o["docs"].Select(doc => new AuthorDTO
{
Id = $"/authors/{(string)doc["key"]}",
Name = (string)doc["name"],
});
return Tuple.Create(numFound, authors);
}
}
}

@ -0,0 +1,97 @@
using System.Globalization;
using LibraryDTO;
using Newtonsoft.Json.Linq;
namespace JsonReader;
public static class BookJsonReader
{
static Dictionary<string, Languages> languages = new Dictionary<string, Languages>()
{
[@"/languages/fre"] = Languages.French,
[@"/languages/eng"] = Languages.English,
["fre"] = Languages.French,
["eng"] = Languages.English,
[""] = Languages.Unknown
};
public static BookDTO ReadBook(string json)
{
JObject o = JObject.Parse(json);
var l = o["languages"]?.FirstOrDefault("");
Languages lang = l != null ? languages[(string)l["key"]] : Languages.Unknown;
//List<Tuple<string, CultureInfo>> pubDateFormat =new List<Tuple<string, CultureInfo>>()
//{
// Tuple.Create("d MMMM yyyy", CultureInfo.GetCultureInfo("fr-FR")),
// Tuple.Create("MMM dd, yyyy", CultureInfo.InvariantCulture)
//};
//DateTime? publishDate = null;
//foreach(var format in pubDateFormat)
//{
// if(DateTime.TryParseExact((string)o["publish_date"], format.Item1, format.Item2, DateTimeStyles.None, out DateTime readDate))
// {
// publishDate = readDate;
// break;
// }
//}
//if(!publishDate.HasValue)
//{
// publishDate = new DateTime((int)o["publish_date"], 12, 31);
//}
DateTime? publishDate = AuthorJsonReader.ReadDate((string)o["publish_date"]);
BookDTO book = new BookDTO
{
Id = (string)o["key"],
Title = (string)o["title"],
Publishers = o["publishers"].Select(p => (string)p).ToList(),
PublishDate = publishDate.GetValueOrDefault(DateTime.Now),
ISBN13 = (string)o["isbn_13"][0],
NbPages = o["number_of_pages"] != null ? (int)o["number_of_pages"] : -1,
Language = lang,
Format = o.TryGetValue("physical_format", out JToken? f) ? (string)f : null,
Works = o["works"].Select(w => new WorkDTO { Id = (string)w["key"] }).ToList(),
Contributors = o.TryGetValue("contributors", out JToken? contr) ? contr.Select(c => new ContributorDTO { Name = (string)c["name"], Role = (string)c["role"] }).ToList() : new List<ContributorDTO>(),
Authors = o["authors"]?.Select(a => new AuthorDTO { Id = (string)a["key"] }).ToList()
};
if(book.Authors == null)
{
book.Authors = new List<AuthorDTO>();
}
return book;
}
public static Tuple<long, IEnumerable<BookDTO>> GetBooksByAuthor(string json)
{
JObject o = JObject.Parse(json);
long numFound = (long)o["numFound"];
var books = o["docs"].Select(doc => new BookDTO
{
Id = (string)(doc["seed"].First()),
Title = (string)doc["title"],
ISBN13 = (string)(doc["isbn"].First()),
Authors = doc["seed"].Where(s => ((string)s).StartsWith("/authors/"))
.Select(s => new AuthorDTO { Id = (string)s }).ToList(),
Language = languages.GetValueOrDefault((string)(doc["language"].First()))
});
return Tuple.Create(numFound, books);
}
public static Tuple<long, IEnumerable<BookDTO>> GetBooksByTitle(string json)
{
JObject o = JObject.Parse(json);
long numFound = (long)o["numFound"];
var books = o["docs"].Select(doc => new BookDTO
{
Id = (string)(doc["seed"].First()),
Title = (string)doc["title"],
ISBN13 = (string)(doc["isbn"].First()),
Authors = doc["seed"].Where(s => ((string)s).StartsWith("/authors/"))
.Select(s => new AuthorDTO { Id = (string)s }).ToList(),
Language = languages.GetValueOrDefault((string)(doc["language"].First()))
});
return Tuple.Create(numFound, books);
}
}

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,55 @@
using System;
using LibraryDTO;
using Newtonsoft.Json.Linq;
using System.Globalization;
namespace JsonReader
{
public static class WorkJsonReader
{
public static WorkDTO ReadWork(string json, string ratingsJson)
{
JObject o = JObject.Parse(json);
JObject r = JObject.Parse(ratingsJson);
var ratingsDto = new RatingsDTO();
if(r["summary"]["average"].Type != JTokenType.Float)
{
ratingsDto.Average = -1;
ratingsDto.Count = 0;
}
else
{
ratingsDto.Average = (float)r["summary"]["average"];
ratingsDto.Count = (int)r["summary"]["count"];
}
string description = null;
if(o.TryGetValue("description", out JToken? descr))
{
if(descr.Type == JTokenType.String)
{
description = (string)descr;
}
else
{
if (descr["value"].Type == JTokenType.String)
{
description = (string)descr["value"];
}
}
}
WorkDTO work = new WorkDTO
{
Id = (string)o["key"],
Title = (string)o["title"],
Authors = o.TryGetValue("authors", out JToken? authors) ? authors.Select(a => new AuthorDTO { Id = (string)a["author"]["key"] }).ToList() : new List<AuthorDTO>(),
Description = description,
Subjects = o.TryGetValue("subjects", out JToken? subjects) ? subjects.Select(s => (string)s).ToList() : new List<string>(),
Ratings = ratingsDto
};
return work;
}
}
}

@ -0,0 +1,18 @@
using System;
namespace LibraryDTO
{
public class AuthorDTO
{
public string Id { get; set; }
public string Name { get; set; }
public string ImageSmall => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-S.jpg";
public string ImageMedium => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-M.jpg";
public string ImageLarge => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-L.jpg";
public string Bio { get; set; }
public List<string> AlternateNames { get; set; } = new List<string>();
public List<LinkDTO> Links { get; set; }
public DateTime? BirthDate { get; set; }
public DateTime? DeathDate { get; set; }
}
}

@ -0,0 +1,23 @@
using System;
namespace LibraryDTO
{
public class BookDTO
{
public string Id { get; set; }
public string Title { get; set; }
public List<string> Publishers { get; set; } = new List<string>();
public DateTime PublishDate { get; set; }
public string ISBN13 { get; set; }
public List<string> Series { get; set; } = new List<string>();
public int NbPages { get; set; }
public string Format { get; set; }
public Languages Language { get; set; }
public List<ContributorDTO> Contributors { get; set; }
public string ImageSmall => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-S.jpg";
public string ImageMedium => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-M.jpg";
public string ImageLarge => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-L.jpg";
public List<WorkDTO> Works { get; set; } = new List<WorkDTO>();
public List<AuthorDTO> Authors { get; set; } = new List<AuthorDTO>();
}
}

@ -0,0 +1,10 @@
using System;
namespace LibraryDTO
{
public class ContributorDTO
{
public string Name { get; set; }
public string Role { get; set; }
}
}

@ -0,0 +1,11 @@
using System;
namespace LibraryDTO
{
public enum Languages
{
Unknown,
French,
English
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
</Project>

@ -0,0 +1,10 @@
using System;
namespace LibraryDTO
{
public class LinkDTO
{
public string Title { get; set; }
public string Url { get; set; }
}
}

@ -0,0 +1,10 @@
using System;
namespace LibraryDTO
{
public class RatingsDTO
{
public float Average { get; set; }
public int Count { get; set; }
}
}

@ -0,0 +1,14 @@
using System;
namespace LibraryDTO
{
public class WorkDTO
{
public string Id { get; set; }
public string Description { get; set; }
public string Title { get; set; }
public List<string> Subjects { get; set; } = new List<string>();
public List<AuthorDTO> Authors { get; set; } = new List<AuthorDTO>();
public RatingsDTO Ratings { get; set; }
}
}

@ -0,0 +1,89 @@
using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.Extensions.Options;
using MyLibraryEntities;
namespace MyLibraryDB;
public class MyLibraryContext : DbContext
{
public DbSet<AuthorEntity> Authors { get; set; }
public DbSet<BookEntity> Books { get; set; }
public DbSet<WorkEntity> Works { get; set; }
public MyLibraryContext()
{ }
public MyLibraryContext(DbContextOptions<MyLibraryContext> options)
: base(options)
{ }
private static DbContextOptions<MyLibraryContext> InitPlaftormDB(string dbPlatformPath)
{
var options = new DbContextOptionsBuilder<MyLibraryContext>()
.UseMySql($"{dbPlatformPath}", new MySqlServerVersion(new Version(10, 11, 1)))
.Options;
return options;
}
public MyLibraryContext(string dbPlatformPath)
: this(InitPlaftormDB(dbPlatformPath))
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source=MylibraryDB.db");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<AuthorEntity>()
.Property(e => e.AlternateNames)
.HasConversion(
v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null),
v => JsonSerializer.Deserialize<List<string>>(v, (JsonSerializerOptions)null),
new ValueComparer<ICollection<string>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => (ICollection<string>)c.ToList()));
modelBuilder.Entity<WorkEntity>()
.Property(e => e.Subjects)
.HasConversion(
v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null),
v => JsonSerializer.Deserialize<List<string>>(v, (JsonSerializerOptions)null),
new ValueComparer<ICollection<string>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => (ICollection<string>)c.ToList()));
modelBuilder.Entity<BookEntity>()
.Property(e => e.Publishers)
.HasConversion(
v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null),
v => JsonSerializer.Deserialize<List<string>>(v, (JsonSerializerOptions)null),
new ValueComparer<ICollection<string>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => (ICollection<string>)c.ToList()));
modelBuilder.Entity<BookEntity>()
.Property(e => e.Series)
.HasConversion(
v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null),
v => JsonSerializer.Deserialize<List<string>>(v, (JsonSerializerOptions)null),
new ValueComparer<ICollection<string>>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => (ICollection<string>)c.ToList()));
}
}

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyLibraryEntities\MyLibraryEntities.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,38 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyLibraryEntities
{
[Table("Authors")]
public class AuthorEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }
[Required]
public string Name { get; set; }
public string? Bio { get; set; }
public ICollection<string>? AlternateNames { get; set; } = new List<string>();
public string SmallImage { get; set; }
public string MediumImage { get; set; }
public string LargeImage { get; set; }
public List<LinkEntity> Links { get; set; }
[Column("BirthDate", TypeName = "date")]
public DateTime? BirthDate { get; set; }
[Column("DeathDate", TypeName = "date")]
public DateTime? DeathDate { get; set; }
public List<WorkEntity> Works { get; } = new ();
public List<BookEntity> Books { get; } = new ();
}
}

@ -0,0 +1,23 @@
using System;
namespace MyLibraryEntities
{
public class BookEntity
{
public string Id { get; set; }
public string Title { get; set; }
public ICollection<string> Publishers { get; set; } = new List<string>();
public DateTime PublishDate { get; set; }
public string ISBN13 { get; set; }
public ICollection<string> Series { get; set; } = new List<string>();
public int NbPages { get; set; }
public string? Format { get; set; }
public Languages Language { get; set; }
public List<ContributorEntity> Contributors { get; set; }
public List<WorkEntity> Works { get; } = new ();
public List<AuthorEntity> Authors { get; } = new ();
public string SmallImage { get; set; }
public string MediumImage { get; set; }
public string LargeImage { get; set; }
}
}

@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace MyLibraryEntities;
public class ContributorEntity
{
public string Id { get; set; }
public string Name { get; set; }
public string Role { get; set; }
[ForeignKey("BookId")]
public BookEntity Book { get; set; }
public string BookId { get; set; }
}

@ -0,0 +1,11 @@
using System;
namespace MyLibraryEntities
{
public enum Languages
{
Unknown,
French,
English
}
}

@ -0,0 +1,18 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyLibraryEntities
{
public class LinkEntity
{
public string Id { get; set; }
public string Title { get; set; }
public string Url { get; set; }
[ForeignKey("AuthorId")]
public AuthorEntity Author { get; set; }
public string AuthorId { get; set; }
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
</Project>

@ -0,0 +1,17 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyLibraryEntities
{
public class StringEntity
{
public string Id { get; set; }
public string Value { get; set; }
[ForeignKey("AuthorId")]
public AuthorEntity Author { get; set; }
public string AuthorId { get; set; }
}
}

@ -0,0 +1,23 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyLibraryEntities
{
public class WorkEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; }
public string? Description { get; set; }
[Required]
public string Title { get; set; }
public ICollection<string>? Subjects { get; set; } = new List<string>();
public List<AuthorEntity> Authors { get; } = new ();
public List<BookEntity> Books { get; } = new ();
//public RatingsEntity Ratings { get; set; }
public float? RatingsAverage { get; set; }
public int? RatingsCount { get; set; }
}
}

@ -0,0 +1,84 @@
using System;
using LibraryDTO;
using MyLibraryEntities;
namespace MyLibraryManager
{
public static class Entity2DtoExtensions
{
public static LibraryDTO.Languages ToDto(this MyLibraryEntities.Languages lang)
{
return Enum.GetValues<LibraryDTO.Languages>().SingleOrDefault(v =>
Enum.GetName<LibraryDTO.Languages>(v) == Enum.GetName<MyLibraryEntities.Languages>(lang));
}
public static AuthorDTO ToDto(this AuthorEntity entity)
{
return new AuthorDTO
{
Id = entity.Id,
AlternateNames = entity.AlternateNames != null ? new List<string>(entity.AlternateNames.Where(an => an != null)) : new List<string>(),
Bio = entity.Bio,
BirthDate = entity.BirthDate,
DeathDate = entity.DeathDate,
Name = entity.Name,
Links = entity.Links != null ? new List<LinkDTO>(entity.Links.Where(l => l != null).ToDtos()) : new List<LinkDTO>(),
};
}
public static IEnumerable<AuthorDTO> ToDtos(this IEnumerable<AuthorEntity> entities)
=> entities.Select(a => a.ToDto());
public static LinkDTO ToDto(this LinkEntity entity)
=> new LinkDTO { Title = entity.Title, Url = entity.Url };
public static IEnumerable<LinkDTO> ToDtos(this IEnumerable<LinkEntity> entities)
=> entities.Select(l => l.ToDto());
public static WorkDTO ToDto(this WorkEntity entity)
{
return new WorkDTO
{
Id = entity.Id,
Description = entity.Description,
Ratings = entity.RatingsAverage != null ?
new RatingsDTO { Average = entity.RatingsAverage.Value, Count = entity.RatingsCount.Value } : null,
Subjects = new List<string>(entity.Subjects),
Title = entity.Title,
Authors = new List<AuthorDTO>(entity.Authors.ToDtos()),
};
}
public static IEnumerable<WorkDTO> ToDtos(this IEnumerable<WorkEntity> entities)
=> entities.Select(w => w.ToDto());
public static ContributorDTO ToDto(this ContributorEntity entity)
=> new ContributorDTO { Name = entity.Name, Role = entity.Role };
public static IEnumerable<ContributorDTO> ToDtos(this IEnumerable<ContributorEntity> entities)
=> entities.Select(l => l.ToDto());
public static BookDTO ToDto(this BookEntity entity)
{
return new BookDTO
{
Id = entity.Id,
Authors = entity.Authors != null ? new List<AuthorDTO>(entity.Authors.ToDtos()) : null,
Contributors = entity.Contributors != null ? new List<ContributorDTO>(entity.Contributors.ToDtos()) : null,
Format = entity.Format,
ISBN13 = entity.ISBN13,
Language = entity.Language.ToDto(),
NbPages = entity.NbPages,
PublishDate = entity.PublishDate,
Publishers = new List<string>(entity.Publishers),
Series = new List<string>(entity.Series),
Title = entity.Title,
Works = new List<WorkDTO>(entity.Works.ToDtos()),
};
}
public static IEnumerable<BookDTO> ToDtos(this IEnumerable<BookEntity> entities)
=> entities.Select(b => b.ToDto());
}
}

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DtoAbstractLayer\DtoAbstractLayer.csproj" />
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
<ProjectReference Include="..\MyLibraryDB\MyLibraryDB.csproj" />
<ProjectReference Include="..\MyLibraryEntities\MyLibraryEntities.csproj" />
<ProjectReference Include="..\StubbedDB\StubbedDB.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,124 @@
using System.Data.SqlTypes;
using DtoAbstractLayer;
using LibraryDTO;
using Microsoft.EntityFrameworkCore;
using MyLibraryDB;
using MyLibraryEntities;
using StubbedDB;
namespace MyLibraryManager;
public class MyLibraryMgr : IDtoManager
{
protected MyLibraryContext Context => _dbContext;
private readonly MyLibraryContext _dbContext;
public MyLibraryMgr() : this(new MyLibraryStubbedContext())
{
}
public MyLibraryMgr(string dbPlatformPath)
: this(new MyLibraryStubbedContext(dbPlatformPath))
{
Context.Database.EnsureCreated();
}
internal MyLibraryMgr(MyLibraryStubbedContext context)
{
_dbContext = context;
}
public async Task<AuthorDTO> GetAuthorById(string id)
{
var author = await Context.Authors.SingleOrDefaultAsync(a => a.Id.ToUpper().Contains(id.ToUpper()));
return author.ToDto();
}
public async Task<Tuple<long, IEnumerable<AuthorDTO>>> GetAuthorsByName(string substring, int index, int count, string sort = "")
{
var authors = Context.Authors.Where(a => a.Name.ToUpper().Contains(substring.ToUpper()));
switch(sort)
{
case "name":
authors = authors.OrderBy(a => a.Name);
break;
case "name_reverse":
authors = authors.OrderByDescending(a => a.Name);
break;
default:
break;
}
long nb = await authors.CountAsync();
return await Task.FromResult(Tuple.Create(nb, authors.Skip(index*count).Take(count).ToDtos()));
}
public async Task<BookDTO> GetBookById(string id)
{
var book = await Context.Books.SingleOrDefaultAsync(b => b.Id.ToUpper().Contains(id.ToUpper()));
return book.ToDto();
}
public async Task<BookDTO> GetBookByISBN(string isbn)
{
var book = await Context.Books.SingleOrDefaultAsync(b => b.ISBN13 == isbn);
return book?.ToDto();
}
Func<AuthorEntity, string, bool> predicateAuthorName =(a, s) => a.Name.ToUpper().Contains(s.ToUpper());
//|| a.AlternateNames.Count(an => an.ToUpper().Contains(s.ToUpper())) > 0;
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthor(string author, int index, int count, string sort = "")
{
var books2 = Context.Books.SelectMany(b => b.Authors, (b, a) => new {Book = b, AuthorName = a.Name });
var books3 = books2.Where(ba => ba.AuthorName.ToUpper().Contains(author.ToUpper()));
var books4 = books3.Select(ba => ba.Book).Distinct();
// var books = Context.Books.Where(b => b.Authors.Where(a => a.Name.ToUpper().Contains(author.ToUpper())).Count() > 0);// Exists(a => predicateAuthorName(a, author)));
return await SortAndFilterBooks(books4, index, count, sort);
}
private async Task<Tuple<long, IEnumerable<BookDTO>>> SortAndFilterBooks(IQueryable<BookEntity>? books, int index, int count, string sort = "")
{
switch(sort)
{
case "title":
books = books.OrderBy(a => a.Title);
break;
case "title_reverse":
books = books.OrderByDescending(a => a.Title);
break;
case "new":
books = books.OrderByDescending(a => a.PublishDate);
break;
case "old":
books = books.OrderBy(a => a.PublishDate);
break;
default:
break;
}
long nb = await books.CountAsync();
return await Task.FromResult(Tuple.Create(nb, books.Skip(index*count).Take(count).ToDtos()));
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "")
{
//var books = Context.Books.Where(b => b.Authors.Count(a => a.Id == authorId) > 0);
var books2 = Context.Books.SelectMany(b => b.Authors, (b, a) => new {Book = b, AuthorId = a.Id });
var books3 = books2.Where(ba => ba.AuthorId.ToUpper().Contains(authorId.ToUpper()));
var books4 = books3.Select(ba => ba.Book).Distinct();
return await SortAndFilterBooks(books4, index, count, sort);
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByTitle(string title, int index, int count, string sort = "")
{
var books = Context.Books.Where(b => b.Title.ToUpper().Contains(title.ToUpper()));
return await SortAndFilterBooks(books, index, count, sort);
}
}

@ -0,0 +1,104 @@
using System;
using System.Data.SqlTypes;
using System.Net;
using System.Text.Json;
using DtoAbstractLayer;
using JsonReader;
using LibraryDTO;
using static System.Net.WebRequestMethods;
namespace OpenLibraryClient;
public class OpenLibClientAPI : IDtoManager
{
const string BasePath = @"https://openlibrary.org/";
const string SearchAuthorPrefix = @"search/authors.json?q=";
const string SearchBookTitlePrefix = @"search.json?title=";
const string SearchBookByAuthorPrefix = @"search.json?author=";
const string AuthorPrefix = @"authors/";
const string BookPrefix = @"books/";
const string IsbnPrefix = @"isbn/";
HttpClient client = new HttpClient();
JsonSerializerOptions SerializerOptions { get; set; } = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
};
private async Task<T> GetElement<T>(string route, Func<string,T> deserializer)
{
try
{
T result = default(T);
Uri uri = new Uri (route, UriKind.RelativeOrAbsolute);
HttpResponseMessage response = await client.GetAsync (uri);
if (response.IsSuccessStatusCode)
{
string content = await response.Content.ReadAsStringAsync ();
result = deserializer(content);
}
return result;
}
catch(Exception exc)
{
throw new WebException($"The route {route} seems to be invalid");
}
}
public async Task<AuthorDTO> GetAuthorById(string id)
{
string route = $"{BasePath}{AuthorPrefix}{id}.json";
return await GetElement<AuthorDTO>(route, json => AuthorJsonReader.ReadAuthor(json));
}
public async Task<Tuple<long, IEnumerable<AuthorDTO>>> GetAuthorsByName(string substring, int index, int count, string sort = "")
{
string searchedString = substring.Trim().Replace(" ", "+");
string route = $"{BasePath}{SearchAuthorPrefix}{searchedString}"
.AddPagination(index, count)
.AddSort(sort);
return await GetElement<Tuple<long, IEnumerable<AuthorDTO>>>(route, json => AuthorJsonReader.GetAuthorsByName(json));
}
public async Task<BookDTO> GetBookById(string id)
{
string route = $"{BasePath}{BookPrefix}{id}.json";
return await GetElement<BookDTO>(route, json => BookJsonReader.ReadBook(json));
}
public async Task<BookDTO> GetBookByISBN(string isbn)
{
string route = $"{BasePath}{IsbnPrefix}{isbn}.json";
return await GetElement<BookDTO>(route, json => BookJsonReader.ReadBook(json));
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthor(string author, int index, int count, string sort = "")
{
string searchedString = author.Trim().Replace(" ", "+");
string route = $"{BasePath}{SearchBookByAuthorPrefix}{searchedString}"
.AddPagination(index, count)
.AddSort(sort);
return await GetElement<Tuple<long, IEnumerable<BookDTO>>>(route, json => BookJsonReader.GetBooksByAuthor(json));
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "")
{
string searchedString = authorId.Trim().Replace(" ", "+");
string route = $"{BasePath}{SearchBookByAuthorPrefix}{searchedString}"
.AddPagination(index, count)
.AddSort(sort);
return await GetElement<Tuple<long, IEnumerable<BookDTO>>>(route, json => BookJsonReader.GetBooksByAuthor(json));
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByTitle(string title, int index, int count, string sort = "")
{
string searchedString = title.Trim().Replace(" ", "+");
string route = $"{BasePath}{SearchBookTitlePrefix}{searchedString}"
.AddPagination(index, count)
.AddSort(sort);
return await GetElement<Tuple<long, IEnumerable<BookDTO>>>(route, json => BookJsonReader.GetBooksByTitle(json));
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
<ProjectReference Include="..\DtoAbstractLayer\DtoAbstractLayer.csproj" />
<ProjectReference Include="..\JsonReader\JsonReader.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,33 @@
using System;
namespace OpenLibraryClient
{
public static class RouteExtensions
{
public static string AddPagination(this string route, int index, int count)
{
if(index <= -1 || count<0)
{
return route;
}
string delimiter = route.Contains("?") ? "&" : "?";
return $"{route}{delimiter}limit={count}&page={index+1}";
}
public static string AddSort(this string route, string sort)
{
string sortCriterium = sort switch
{
"new" => "new",
"old" => "old",
"random" => "random",
"key" => "key",
_ => null
};
if(sortCriterium == null) return route;
string delimiter = route.Contains("?") ? "&" : "?";
return $"{route}{delimiter}sort={sortCriterium}";
}
}
}

@ -0,0 +1,99 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1705.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLibraryWrapper", "OpenLibraryWrapper\OpenLibraryWrapper.csproj", "{EF0DED5C-7559-4D43-A30B-AE916FCDA078}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0D260EDC-4F17-4BA4-9306-B6FEC6E5E394}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryDTO", "LibraryDTO\LibraryDTO.csproj", "{F59D46BA-6734-464E-8AC4-759BEFB87973}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedDTO", "StubbedDTO\StubbedDTO.csproj", "{3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DtoAbstractLayer", "DtoAbstractLayer\DtoAbstractLayer.csproj", "{43E49F05-E257-441B-B5E4-C82DBE4DDF1A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonReader", "JsonReader\JsonReader.csproj", "{4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5C6B8D83-705A-4BBD-BBA0-A86ACB370B33}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLibraryClient", "OpenLibraryClient\OpenLibraryClient.csproj", "{3A429457-D882-44E3-B65E-107554C2E91F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyLibraryEntities", "MyLibraryEntities\MyLibraryEntities.csproj", "{4E54987D-1790-49F9-9027-700A894B2BD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyLibraryDB", "MyLibraryDB\MyLibraryDB.csproj", "{0ED941B5-E5C9-4A54-BAC8-4F7FB44F2947}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedDB", "StubbedDB\StubbedDB.csproj", "{951F7FDA-FA71-46CA-9DDE-4DF0AAAC9DA9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLibraryWrapper_UT", "Tests\OpenLibraryWrapper_UT\OpenLibraryWrapper_UT.csproj", "{7FA060D6-3490-4FE3-808F-06370DF8A3B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyLibraryDB_Tests", "Tests\MyLibraryDB_Tests\MyLibraryDB_Tests.csproj", "{A3137A3B-7BA6-4AC8-80C6-653F50079D55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyLibraryManager", "MyLibraryManager\MyLibraryManager.csproj", "{DA2B0562-31DA-4059-B402-404EC31874B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Release|Any CPU.Build.0 = Release|Any CPU
{F59D46BA-6734-464E-8AC4-759BEFB87973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F59D46BA-6734-464E-8AC4-759BEFB87973}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F59D46BA-6734-464E-8AC4-759BEFB87973}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F59D46BA-6734-464E-8AC4-759BEFB87973}.Release|Any CPU.Build.0 = Release|Any CPU
{3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Release|Any CPU.Build.0 = Release|Any CPU
{43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Release|Any CPU.Build.0 = Release|Any CPU
{4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Release|Any CPU.Build.0 = Release|Any CPU
{3A429457-D882-44E3-B65E-107554C2E91F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A429457-D882-44E3-B65E-107554C2E91F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A429457-D882-44E3-B65E-107554C2E91F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A429457-D882-44E3-B65E-107554C2E91F}.Release|Any CPU.Build.0 = Release|Any CPU
{4E54987D-1790-49F9-9027-700A894B2BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E54987D-1790-49F9-9027-700A894B2BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E54987D-1790-49F9-9027-700A894B2BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E54987D-1790-49F9-9027-700A894B2BD9}.Release|Any CPU.Build.0 = Release|Any CPU
{0ED941B5-E5C9-4A54-BAC8-4F7FB44F2947}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0ED941B5-E5C9-4A54-BAC8-4F7FB44F2947}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0ED941B5-E5C9-4A54-BAC8-4F7FB44F2947}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0ED941B5-E5C9-4A54-BAC8-4F7FB44F2947}.Release|Any CPU.Build.0 = Release|Any CPU
{951F7FDA-FA71-46CA-9DDE-4DF0AAAC9DA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{951F7FDA-FA71-46CA-9DDE-4DF0AAAC9DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{951F7FDA-FA71-46CA-9DDE-4DF0AAAC9DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{951F7FDA-FA71-46CA-9DDE-4DF0AAAC9DA9}.Release|Any CPU.Build.0 = Release|Any CPU
{7FA060D6-3490-4FE3-808F-06370DF8A3B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FA060D6-3490-4FE3-808F-06370DF8A3B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FA060D6-3490-4FE3-808F-06370DF8A3B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FA060D6-3490-4FE3-808F-06370DF8A3B9}.Release|Any CPU.Build.0 = Release|Any CPU
{A3137A3B-7BA6-4AC8-80C6-653F50079D55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3137A3B-7BA6-4AC8-80C6-653F50079D55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3137A3B-7BA6-4AC8-80C6-653F50079D55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3137A3B-7BA6-4AC8-80C6-653F50079D55}.Release|Any CPU.Build.0 = Release|Any CPU
{DA2B0562-31DA-4059-B402-404EC31874B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA2B0562-31DA-4059-B402-404EC31874B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA2B0562-31DA-4059-B402-404EC31874B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA2B0562-31DA-4059-B402-404EC31874B6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2E40DC1C-BE57-48E8-B7C2-B9CFF589DB5B}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7FA060D6-3490-4FE3-808F-06370DF8A3B9} = {0D260EDC-4F17-4BA4-9306-B6FEC6E5E394}
{A3137A3B-7BA6-4AC8-80C6-653F50079D55} = {0D260EDC-4F17-4BA4-9306-B6FEC6E5E394}
EndGlobalSection
EndGlobal

@ -0,0 +1,289 @@
using System;
using DtoAbstractLayer;
using LibraryDTO;
using Microsoft.AspNetCore.Mvc;
using StubbedDTO;
using OpenLibraryClient;
using MyLibraryManager;
namespace OpenLibraryWrapper.Controllers
{
[ApiController]
[Route("[controller]")]
public class BookController : ControllerBase
{
private readonly ILogger<BookController> _logger;
private IDtoManager DtoManager;
public BookController(ILogger<BookController> logger, IDtoManager dtoManager)
{
_logger = logger;
var dbDatabase = System.Environment.GetEnvironmentVariable("DB_DATABASE", System.EnvironmentVariableTarget.Process);
switch(dbDatabase){
case "marcthierydb":
//DtoManager = new MyLibraryMgr();
DtoManager = new Stub();
break;
case "marcthieryAPI":
DtoManager = new OpenLibClientAPI();
break;
default:
DtoManager = new Stub();
break;
}
}
/// <summary>
/// Gets books of the collection matching a particular title
/// </summary>
/// <param name="title">part of a title to look for in book titles (case is ignored)</param>
/// <param name="index">index of the page</param>
/// <param name="count">number of elements per page</param>
/// <param name="sort">sort criterium of the resulting books:
/// <ul>
/// <li>```title```: sort books by titles in alphabetical order,</li>
/// <li>```title_reverse```: sort books by titles in reverse alphabetical order,</li>
/// <li>```new```: sort books by publishing dates, beginning with the most recents,</li>
/// <li>```old```: sort books by publishing dates, beginning with the oldest</li>
/// </ul>
///
/// </param>
/// <returns>a collection of count (or less) books</returns>
/// <remarks>
/// Sample requests:
///
/// book/getbooksbytitle?title=ne&amp;index=0&amp;count=5
/// book/getbooksbytitle?title=ne&amp;index=0&amp;count=5&amp;sort=old
///
/// </remarks>
/// <response code="200">Returns count books at page index</response>
/// <response code="404">no books within this range</response>
[HttpGet("getBooksByTitle")]
[ProducesResponseType(typeof(Tuple<long, IEnumerable<BookDTO>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetBooksByTitle([FromQuery] string title, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "")
{
_logger.LogDebug("Get books by title");
var booksDto = (await DtoManager.GetBooksByTitle(title, index, count, sort));
_logger.LogInformation($"{booksDto.Item1} books found");
if(booksDto.Item1 == 0)
{
return NotFound();
}
return Ok(booksDto);
}
/// <summary>
/// Gets books of the collection whose of one the authors is matching a particular name
/// </summary>
/// <param name="name">part of a author name to look for in book authors (case is ignored)</param>
/// <param name="index">index of the page</param>
/// <param name="count">number of elements per page</param>
/// <param name="sort">sort criterium of the resulting books:
/// <ul>
/// <li>```title```: sort books by titles in alphabetical order,</li>
/// <li>```title_reverse```: sort books by titles in reverse alphabetical order,</li>
/// <li>```new```: sort books by publishing dates, beginning with the most recents,</li>
/// <li>```old```: sort books by publishing dates, beginning with the oldest</li>
/// </ul>
///
/// </param>
/// <returns>a collection of count (or less) books</returns>
/// <remarks>
/// Sample requests:
///
/// book/getbooksbyauthor?name=al&amp;index=0&amp;count=5
/// book/getbooksbyauthor?name=al&amp;index=0&amp;count=5&amp;sort=old
///
/// <b>Note:</b>
/// <i>name is also looked for in alternate names of the authors</i>
/// </remarks>
/// <response code="200">Returns count books at page index</response>
/// <response code="404">no books within this range</response>
[HttpGet("getBooksByAuthor")]
[ProducesResponseType(typeof(Tuple<long, IEnumerable<BookDTO>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetBooksByAuthor([FromQuery] string name, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "")
{
_logger.LogDebug("Get books by author");
var booksDto = (await DtoManager.GetBooksByAuthor(name, index, count, sort));
_logger.LogInformation($"{booksDto.Item1} books found");
if(booksDto.Item1 == 0)
{
return NotFound();
}
return Ok(booksDto);
}
/// <summary>
/// Gets books of the collection of a particular author
/// </summary>
/// <param name="id">id of the author</param>
/// <param name="index">index of the page</param>
/// <param name="count">number of elements per page</param>
/// <param name="sort">sort criterium of the resulting books:
/// <ul>
/// <li>```title```: sort books by titles in alphabetical order,</li>
/// <li>```title_reverse```: sort books by titles in reverse alphabetical order,</li>
/// <li>```new```: sort books by publishing dates, beginning with the most recents,</li>
/// <li>```old```: sort books by publishing dates, beginning with the oldest</li>
/// </ul>
///
/// </param>
/// <returns>a collection of count (or less) books</returns>
/// <remarks>
/// Sample requests:
///
/// book/getbooksbyauthorid?id=OL1846639A&amp;index=0&amp;count=5
/// book/getbooksbyauthorid?id=OL1846639A&amp;index=0&amp;count=5&amp;sort=old
///
/// </remarks>
/// <response code="200">Returns count books at page index</response>
/// <response code="404">no books within this range</response>
[HttpGet("getBooksByAuthorId")]
[ProducesResponseType(typeof(Tuple<long, IEnumerable<BookDTO>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetBooksByAuthorId([FromQuery] string id, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "")
{
_logger.LogDebug("Get books by author id");
var booksDto = (await DtoManager.GetBooksByAuthorId(id, index, count, sort));
_logger.LogInformation($"{booksDto.Item1} books found");
if(booksDto.Item1 == 0)
{
return NotFound();
}
return Ok(booksDto);
}
/// <summary>
/// Gets authors of the collection matching a particular name
/// </summary>
/// <param name="name">name to look for in author names</param>
/// <param name="index">index of the page</param>
/// <param name="count">number of elements per page</param>
/// <param name="sort">sort criterium of the resulting authors:
/// <ul>
/// <li>```name```: sort authors by names in alphabetical order,</li>
/// <li>```name_reverse```: sort authors by names in reverse alphabetical order,</li>
/// </ul>
///
/// </param>
/// <returns>a collection of count (or less) authors</returns>
/// <remarks>
/// Sample requests:
///
/// book/getauthorsbyname?name=al&amp;index=0&amp;count=5
/// book/getauthorsbyname?name=al&amp;index=0&amp;count=5&amp;sort=name
///
/// </remarks>
/// <response code="200">Returns count authors at page index</response>
/// <response code="404">no authors within this range</response>
[HttpGet("getAuthorsByName")]
[ProducesResponseType(typeof(Tuple<long, IEnumerable<AuthorDTO>>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetAuthorsByName([FromQuery] string name, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "")
{
_logger.LogDebug("Get authors by name");
var authorsDto = (await DtoManager.GetAuthorsByName(name, index, count, sort));
_logger.LogInformation($"{authorsDto.Item1} authors found");
if(authorsDto.Item1 == 0)
{
return NotFound();
}
return Ok(authorsDto);
}
/// <summary>
/// Gets book by isbn
/// </summary>
/// <param name="isbn">isbn of the book to get</param>
/// <returns>the book with the seeked isbn (or null)</returns>
/// <remarks>
/// Sample requests:
///
/// book/getBookByIsbn/9782330033118
///
/// </remarks>
/// <response code="200">Returns the book with this isbn</response>
/// <response code="404">no book found</response>
[HttpGet("getBookByIsbn/{isbn?}")]
[ProducesResponseType(typeof(BookDTO), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetBookByIsbn(string isbn)
{
_logger.LogDebug("Get book by isbn");
var bookDto = (await DtoManager.GetBookByISBN(isbn));
if(bookDto == null)
{
_logger.LogInformation($"{isbn} not found");
return NotFound();
}
_logger.LogInformation($"{bookDto.Title} found");
return Ok(bookDto);
}
/// <summary>
/// Gets book by id
/// </summary>
/// <param name="id">id of the book to get</param>
/// <returns>the book with the seeked id (or null)</returns>
/// <remarks>
/// Sample requests:
///
/// book/getBookById/OL25910297M
///
/// </remarks>
/// <response code="200">Returns the book with this id</response>
/// <response code="404">no book found</response>
[HttpGet("getBookById/{id?}")]
[ProducesResponseType(typeof(BookDTO), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetBookById(string id)
{
_logger.LogDebug("Get book by ID");
var bookDto = (await DtoManager.GetBookById(id));
if(bookDto == null)
{
_logger.LogInformation($"{id} not found");
return NotFound();
}
_logger.LogInformation($"{bookDto.Title} found");
return Ok(bookDto);
}
/// <summary>
/// Gets author by id
/// </summary>
/// <param name="id">id of the author to get</param>
/// <returns>the author with the seeked id (or null)</returns>
/// <remarks>
/// Sample requests:
///
/// book/getAuthorById/OL1846639A
///
/// </remarks>
/// <response code="200">Returns the author with this id</response>
/// <response code="404">no author found</response>
[HttpGet("getAuthorById/{id?}")]
[ProducesResponseType(typeof(AuthorDTO), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetAuthorById(string id)
{
_logger.LogDebug("Get Author by ID");
var authorDTO = (await DtoManager.GetAuthorById(id));
if(authorDTO == null)
{
_logger.LogInformation($"{id} not found");
return NotFound();
}
_logger.LogInformation($"{authorDTO.Name} found");
return Ok(authorDTO);
}
}
}

@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " />
<PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
<ProjectReference Include="..\StubbedDTO\StubbedDTO.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
<ProjectReference Include="..\DtoAbstractLayer\DtoAbstractLayer.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
<ProjectReference Include="..\OpenLibraryClient\OpenLibraryClient.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
<ProjectReference Include="..\MyLibraryManager\MyLibraryManager.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Condition=" '$(EnableDefaultCompileItems)' == 'true' " Update="Program.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
</ItemGroup>
</Project>

@ -0,0 +1,33 @@
using System.Reflection;
using DtoAbstractLayer;
using LibraryDTO;
using Microsoft.OpenApi.Models;
using MyLibraryManager;
using OpenLibraryClient;
using StubbedDTO;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddSingleton<IDtoManager, Stub>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,49 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:34424",
"sslPort": 44344
}
},
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5117",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7263;http://localhost:5117",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OpenLibraryWrapper": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:34198;http://localhost:46179",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

@ -0,0 +1,115 @@
using System;
using StubbedDTO;
using System.Linq;
using LibraryDTO;
using MyLibraryEntities;
namespace StubbedDB
{
public static class Json2Data
{
public static MyLibraryEntities.Languages ToEntity(this LibraryDTO.Languages lang)
{
return Enum.GetValues<MyLibraryEntities.Languages>().SingleOrDefault(v =>
Enum.GetName<MyLibraryEntities.Languages>(v) == Enum.GetName<LibraryDTO.Languages>(lang));
}
public static IEnumerable<AuthorEntity> ToAuthorsData()
{
var temp = Stub.Authors.Select(a =>
new AuthorEntity
{
Id = a.Id,
Name = a.Name,
Bio = a.Bio,
BirthDate = a.BirthDate,
DeathDate = a.DeathDate,
SmallImage = $"https://covers.openlibrary.org/a/olid/{a.Id.Substring(a.Id.LastIndexOf("/"))}-S.jpg",
MediumImage = $"https://covers.openlibrary.org/a/olid/{a.Id.Substring(a.Id.LastIndexOf("/"))}-M.jpg",
LargeImage = $"https://covers.openlibrary.org/a/olid/{a.Id.Substring(a.Id.LastIndexOf("/"))}-L.jpg",
AlternateNames = a.AlternateNames
});
return temp;
}
public static IEnumerable<object> ToLinksData()
{
return Stub.Authors.Where(a => a.Links != null && a.Links.Count > 0)
.SelectMany(a => a.Links, (author,link) =>
new
{
Id = $"{author.Id.Substring(author.Id.LastIndexOf("/"))}-{author.Links.IndexOf(link)}",
Title = link.Title,
Url = link.Url,
AuthorId = author.Id
});
}
public static IEnumerable<object> ToWorksData()
{
return Stub.Works.Select(w =>
new
{
Id = w.Id,
Description = w.Description,
RatingsAverage = w.Ratings?.Average,
RatingsCount = w.Ratings?.Count,
Title = w.Title,
Subjects = w.Subjects
});
}
public static IEnumerable<object> ToAuthorsWorksData()
{
return Stub.Works.SelectMany(w => w.Authors,
(w, a) => new { AuthorsId = a.Id, WorksId = w.Id });
}
public static IEnumerable<object> ToBooksData()
{
return Stub.Books.Select(b =>
new
{
Publishers = b.Publishers,
Title = b.Title,
NbPages = b.NbPages,
ISBN13 = b.ISBN13,
Language = b.Language.ToEntity(),
PublishDate = b.PublishDate,
Id = b.Id,
Series = b.Series,
Format = b.Format,
SmallImage = $"https://covers.openlibrary.org/b/isbn/{b.ISBN13}-S.jpg",
MediumImage = $"https://covers.openlibrary.org/b/isbn/{b.ISBN13}-M.jpg",
LargeImage = $"https://covers.openlibrary.org/b/isbn/{b.ISBN13}-l.jpg"
});
}
public static IEnumerable<object> ToBooksWorksData()
{
return Stub.Books.SelectMany(b => b.Works,
(b, w) => new {BooksId = b.Id, WorksId = w.Id});
}
public static IEnumerable<object> ToContributorsData()
{
return Stub.Books.SelectMany( b => b.Contributors,
(b, c) => new
{
Id = $"{b.Id}-c{b.Contributors.IndexOf(c)}",
BookId = b.Id,
Name = c.Name,
Role = c.Role
});
}
public static IEnumerable<object> ToAuthorsBooksData()
{
var proj = (BookDTO b, AuthorDTO a) => new { AuthorsId = a.Id, BooksId = b.Id};
var collec1 = Stub.Books.SelectMany(b => b.Authors, proj);
var collec2 = Stub.Books.SelectMany(b => b.Works.SelectMany(w => w.Authors), proj);
return collec1.Union(collec2);
}
}
}

@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using MyLibraryDB;
using MyLibraryEntities;
using static System.Reflection.Metadata.BlobBuilder;
namespace StubbedDB;
public class MyLibraryStubbedContext : MyLibraryContext
{
public MyLibraryStubbedContext() : base() { }
public MyLibraryStubbedContext(string dbPlatformPath)
:base(dbPlatformPath)
{ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<AuthorEntity>().HasData(
Json2Data.ToAuthorsData());
modelBuilder.Entity<LinkEntity>().HasData(
Json2Data.ToLinksData());
modelBuilder.Entity<WorkEntity>().HasData(
Json2Data.ToWorksData());
modelBuilder.Entity("AuthorEntityWorkEntity").HasData(
Json2Data.ToAuthorsWorksData());
modelBuilder.Entity<BookEntity>().HasData(
Json2Data.ToBooksData());
modelBuilder.Entity("BookEntityWorkEntity").HasData(
Json2Data.ToBooksWorksData());
modelBuilder.Entity<ContributorEntity>().HasData(
Json2Data.ToContributorsData());
modelBuilder.Entity("AuthorEntityBookEntity").HasData(
Json2Data.ToAuthorsBooksData());
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyLibraryDB\MyLibraryDB.csproj" />
<ProjectReference Include="..\StubbedDTO\StubbedDTO.csproj" />
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,203 @@
using System.Data.SqlTypes;
using DtoAbstractLayer;
using JsonReader;
using LibraryDTO;
using static System.Reflection.Metadata.BlobBuilder;
namespace StubbedDTO;
public class Stub : IDtoManager
{
public static List<AuthorDTO> Authors { get; set; } = new List<AuthorDTO>();
public static List<BookDTO> Books { get; set; } = new List<BookDTO>();
public static List<WorkDTO> Works { get; set; } = new List<WorkDTO>();
public static string BasePath { get; set; } = "";
static Stub()
{
foreach(var fileAuthor in new DirectoryInfo($"{BasePath}authors/").GetFiles())
{
using(StreamReader reader = File.OpenText(fileAuthor.FullName))
{
Authors.Add(AuthorJsonReader.ReadAuthor(reader.ReadToEnd()));
}
}
foreach(var fileWork in new DirectoryInfo($"{BasePath}works/").GetFiles())
{
var ratingsFile = $"{BasePath}ratings/{fileWork.Name.Insert((int)(fileWork.Name.Length - fileWork.Extension.Length), ".ratings")}";
using(StreamReader reader = File.OpenText(fileWork.FullName))
using(StreamReader readerRatings = File.OpenText(ratingsFile))
{
var work = WorkJsonReader.ReadWork(reader.ReadToEnd(), readerRatings.ReadToEnd());
if(work.Authors != null)
foreach(var author in work.Authors.ToList())
{
var newAuthor = Authors.SingleOrDefault(a => a.Id == author.Id);
work.Authors.Remove(author);
work.Authors.Add(newAuthor);
}
Works.Add(work);
}
}
foreach(var fileBook in new DirectoryInfo($"{BasePath}books/").GetFiles())
{
using(StreamReader reader = File.OpenText(fileBook.FullName))
{
var book = BookJsonReader.ReadBook(reader.ReadToEnd());
foreach(var author in book.Authors.ToList())
{
var newAuthor = Authors.SingleOrDefault(a => a.Id == author.Id);
book.Authors.Remove(author);
book.Authors.Add(newAuthor);
}
foreach(var work in book.Works.ToList())
{
var newWork = Works.SingleOrDefault(w => w.Id == work.Id);
book.Works.Remove(work);
book.Works.Add(newWork);
}
Books.Add(book);
}
}
}
public Task<AuthorDTO> GetAuthorById(string id)
{
var author = Stub.Authors.SingleOrDefault(a => a.Id.Contains(id));
return Task.FromResult(author);
}
private Task<Tuple<long, IEnumerable<AuthorDTO>>> OrderAuthors(IEnumerable<AuthorDTO> authors, int index, int count, string sort = "")
{
switch(sort)
{
case "name":
authors = authors.OrderBy(a => a.Name);
break;
case "name_reverse":
authors = authors.OrderByDescending(a => a.Name);
break;
}
return Task.FromResult(Tuple.Create((long)authors.Count(), authors.Skip(index*count).Take(count)));
}
public async Task<Tuple<long, IEnumerable<AuthorDTO>>> GetAuthors(int index, int count, string sort = "")
{
IEnumerable<AuthorDTO> authors = Stub.Authors;
return await OrderAuthors(authors, index, count, sort);
}
public async Task<Tuple<long, IEnumerable<AuthorDTO>>> GetAuthorsByName(string name, int index, int count, string sort = "")
{
var authors = Stub.Authors.Where(a => a.Name.Contains(name, StringComparison.OrdinalIgnoreCase)
|| a.AlternateNames.Exists(alt => alt.Contains(name, StringComparison.OrdinalIgnoreCase)));
return await OrderAuthors(authors, index, count, sort);
}
public Task<BookDTO> GetBookById(string id)
{
var book = Stub.Books.SingleOrDefault(b => b.Id.Contains(id));
return Task.FromResult(book);
}
private Task<Tuple<long, IEnumerable<BookDTO>>> OrderBooks(IEnumerable<BookDTO> books, int index, int count, string sort = "")
{
switch(sort)
{
case "title":
books = books.OrderBy(b => b.Title);
break;
case "title_reverse":
books = books.OrderByDescending(b => b.Title);
break;
case "new":
books = books.OrderByDescending(b => b.PublishDate);
break;
case "old":
books = books.OrderBy(b => b.PublishDate);
break;
}
return Task.FromResult(Tuple.Create((long)books.Count(), books.Skip(index*count).Take(count)));
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooks(int index, int count, string sort = "")
{
var books = Stub.Books;
return await OrderBooks(books, index, count, sort);
}
public Task<BookDTO> GetBookByISBN(string isbn)
{
var book = Stub.Books.SingleOrDefault(b => b.ISBN13.Equals(isbn, StringComparison.OrdinalIgnoreCase));
return Task.FromResult(book);
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByTitle(string title, int index, int count, string sort = "")
{
var books = Stub.Books.Where(b => b.Title.Contains(title, StringComparison.OrdinalIgnoreCase)
|| b.Series.Exists(s => s.Contains(title, StringComparison.OrdinalIgnoreCase)));
return await OrderBooks(books, index, count, sort);
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "")
{
var books = Stub.Books.Where(b => b.Authors.Exists(a => a.Id.Contains(authorId))
|| b.Works.Exists(w => w.Authors.Exists(a => a.Id.Contains(authorId))));
return await OrderBooks(books, index, count, sort);
}
public async Task<Tuple<long, IEnumerable<BookDTO>>> GetBooksByAuthor(string name, int index, int count, string sort = "")
{
var books = Stub.Books.Where(b => ContainsAuthorName(b, name));
return await OrderBooks(books, index, count, sort);
}
private bool ContainsAuthorName(BookDTO book, string name)
{
IEnumerable<AuthorDTO> authors = new List<AuthorDTO>();
if(book.Authors != null && book.Authors.Count > 0)
{
authors = authors.Union(book.Authors);
}
if(book.Works != null)
{
var worksAuthors = book.Works.SelectMany(w => w.Authors).ToList();
if(worksAuthors.Count > 0)
authors = authors.Union(worksAuthors);
}
foreach(var author in authors)
{
if(author.Name.Contains(name, StringComparison.OrdinalIgnoreCase)
|| author.AlternateNames.Exists(alt => alt.Contains(name, StringComparison.OrdinalIgnoreCase)))
{
return true;
}
}
return false;
}
public Task<Tuple<long, IEnumerable<WorkDTO>>> GetWorks(int index, int count)
{
long nbWorks = Stub.Works.Count;
var works = Stub.Works.Skip(index*count).Take(count);
return Task.FromResult(Tuple.Create(nbWorks, works));
}
public Task<long> GetNbAuthors()
=> Task.FromResult((long)Stub.Authors.Count);
public Task<long> GetNbBooks()
=> Task.FromResult((long)Stub.Books.Count);
public Task<long> GetNbWorks()
=> Task.FromResult((long)Stub.Works.Count);
}

@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="books\" />
<None Remove="authors\" />
<None Remove="works\" />
<None Remove="ratings\" />
</ItemGroup>
<ItemGroup>
<Folder Include="books\" />
<Folder Include="authors\" />
<Folder Include="works\" />
<Folder Include="ratings\" />
</ItemGroup>
<ItemGroup>
<None Include="*\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JsonReader\JsonReader.csproj" />
<ProjectReference Include="..\DtoAbstractLayer\DtoAbstractLayer.csproj" />
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,12 @@
{
"name": "Michel Demuth",
"personal_name": "Michel Demuth",
"last_modified": {
"type": "/type/datetime",
"value": "2008-08-26 02:41:15.604911"
},
"key": "/authors/OL1846639A",
"type": { "key": "/type/author" },
"id": 6527877,
"revision": 2
}

@ -0,0 +1,34 @@
{
"personal_name": "Dick, Philip K.",
"source_records": [ "amazon:8445007327", "bwb:9780722129562", "amazon:0792776232", "ia:pacificpark0000dick", "amazon:2277213799", "amazon:2266163019", "bwb:9798599263227", "amazon:1433276712", "ia:ejonescreoilmond0000dick", "amazon:6051719164", "amazon:6254493632", "amazon:2277117749", "amazon:1987781619", "amazon:1433248239", "amazon:1480594407" ],
"alternate_names": [ "Philip Kindred Dick", "Philip Dick", "Philip Kendred Dick", "Philip K Dick" ],
"bio": "Philip Kindred Dick was an American novelist, short story writer, and essayist whose published work during his lifetime was almost entirely in the science fiction genre. Dick explored sociological, political and metaphysical themes in novels dominated by monopolistic corporations, authoritarian governments, and altered states. In his later works, Dick's thematic focus strongly reflected his personal interest in metaphysics and theology. He often drew upon his own life experiences and addressed the nature of drug abuse, paranoia and schizophrenia, and transcendental experiences in novels such as A Scanner Darkly and VALIS.\r\n\r\nSource and more information: [Wikipedia (EN)](http://en.wikipedia.org/wiki/Philip_K._Dick)",
"type": { "key": "/type/author" },
"death_date": "2 March 1982",
"remote_ids": {
"isni": "0000000121251093",
"wikidata": "Q171091",
"viaf": "27063583"
},
"name": "Philip K. Dick",
"links": [
{
"title": "Wikipedia link to Philip K Dick",
"url": "http://en.wikipedia.org/wiki/Philip_K._Dick",
"type": { "key": "/type/link" }
}
],
"photos": [ 6295259 ],
"birth_date": "16 December 1928",
"key": "/authors/OL274606A",
"latest_revision": 23,
"revision": 23,
"created": {
"type": "/type/datetime",
"value": "2008-04-01T03:28:50.625462"
},
"last_modified": {
"type": "/type/datetime",
"value": "2022-11-29T21:21:41.951561"
}
}

@ -0,0 +1 @@
{"name": "Gilles Goullet", "last_modified": {"type": "/type/datetime", "value": "2008-04-30 08:14:56.482104"}, "key": "/authors/OL3113900A", "type": {"key": "/type/author"}, "id": 11970651, "revision": 1}

@ -0,0 +1,11 @@
{
"name": "H\u00e9l\u00e8ne Collon",
"last_modified": {
"type": "/type/datetime",
"value": "2008-04-30 08:14:56.482104"
},
"key": "/authors/OL3113922A",
"type": { "key": "/type/author" },
"id": 11970257,
"revision": 1
}

@ -0,0 +1,17 @@
{
"name": "Alain Damasio",
"key": "/authors/OL3980331A",
"type": { "key": "/type/author" },
"remote_ids": { "wikidata": "Q2829704" },
"birth_date": "1 August 1969",
"latest_revision": 2,
"revision": 2,
"created": {
"type": "/type/datetime",
"value": "2008-04-30T20:50:18.033121"
},
"last_modified": {
"type": "/type/datetime",
"value": "2022-12-19T19:05:32.693708"
}
}

@ -0,0 +1,36 @@
{
"personal_name": "James S. A. Corey",
"remote_ids": {
"isni": "0000000382626033",
"viaf": "266413968",
"wikidata": "Q6142591"
},
"source_records": [ "amazon:1478933771", "amazon:1528822218", "amazon:1456121650", "bwb:9780356510385", "amazon:0678452547", "bwb:9780356517773" ],
"alternate_names": [ "Daniel Abraham", "Ty Franck", "James S.A. Corey", "James James S. A. Corey" ],
"type": { "key": "/type/author" },
"key": "/authors/OL6982995A",
"entity_type": "org",
"links": [
{
"title": "Source",
"url": "http://www.danielabraham.com/james-s-a-corey/",
"type": { "key": "/type/link" }
}
],
"bio": {
"type": "/type/text",
"value": "James S.A. Corey is the pen name used by collaborators [Daniel Abraham](https://openlibrary.org/authors/OL1427729A/Daniel_Abraham) and [Ty Franck](https://openlibrary.org/authors/OL7523472A/Ty_Franck).\r\n\r\nThe first and last name are taken from Abraham's and Franck's middle names, respectively, and S.A. are the initials of Abraham's daughter."
},
"photos": [ 11112303 ],
"name": "James S. A. Corey",
"latest_revision": 13,
"revision": 13,
"created": {
"type": "/type/datetime",
"value": "2011-10-20T08:06:05.906616"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-05-18T18:14:26.659278"
}
}

@ -0,0 +1,15 @@
{
"key": "/authors/OL7475792A",
"name": "Ada Palmer",
"type": { "key": "/type/author" },
"latest_revision": 4,
"revision": 4,
"created": {
"type": "/type/datetime",
"value": "2019-03-11T19:38:25.579004"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-12-07T07:11:29.213401"
}
}

@ -0,0 +1 @@
{"name": "Robert Charles Wilson", "created": {"type": "/type/datetime", "value": "2020-05-08T21:00:30.785249"}, "last_modified": {"type": "/type/datetime", "value": "2020-05-08T21:00:30.785249"}, "latest_revision": 1, "key": "/authors/OL7876839A", "type": {"key": "/type/author"}, "revision": 1}

@ -0,0 +1,42 @@
{
"remote_ids": {
"viaf": "59083797",
"wikidata": "Q7934",
"isni": "0000000121347853"
},
"name": "Frank Herbert",
"source_records": [ "amazon:3870703903", "amazon:2253113190", "amazon:1427228493" ],
"alternate_names": [ "Herbert, Frank", "FRANK HERBERT", "Frank HERBERT", "herbert-frank", "frank herbert", "Herbert Frank", "Frank Herbert Dost Korpe", "HERBERT FRANK", "Franck Herbert", "F Herbert" ],
"photos": [ 12194537, 7277115, 10643754 ],
"links": [
{
"url": "http://en.wikipedia.org/wiki/Frank_Herbert",
"type": { "key": "/type/link" },
"title": "Wikipedia English"
},
{
"url": "http://fr.wikipedia.org/wiki/Frank_Herbert",
"type": { "key": "/type/link" },
"title": "Wikipedia France"
}
],
"key": "/authors/OL79034A",
"birth_date": "8 October 1920",
"death_date": "11 February 1986",
"type": { "key": "/type/author" },
"personal_name": "Herbert, Frank.",
"bio": {
"type": "/type/text",
"value": "Real name: Franklin Patrick Herbert Jr."
},
"latest_revision": 15,
"revision": 15,
"created": {
"type": "/type/datetime",
"value": "2008-04-01T03:28:50.625462"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-11-12T11:41:55.357817"
}
}

@ -0,0 +1,16 @@
{
"type": { "key": "/type/author" },
"name": "Frank Herbert",
"key": "/authors/OL9956442A",
"source_records": [ "amazon:2221252306" ],
"latest_revision": 1,
"revision": 1,
"created": {
"type": "/type/datetime",
"value": "2021-11-14T17:07:35.515652"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-11-14T17:07:35.515652"
}
}

@ -0,0 +1,24 @@
{
"publishers": [ "Actes Sud" ],
"title": "L'\u00c9veil du L\u00e9viathan",
"number_of_pages": 624,
"isbn_13": [ "9782330033118" ],
"covers": [ 7412481 ],
"languages": [ { "key": "/languages/fre" } ],
"publish_date": "4 juin 2014",
"key": "/books/OL25910297M",
"publish_places": [ "France" ],
"works": [ { "key": "/works/OL17334140W" } ],
"type": { "key": "/type/edition" },
"source_records": [ "amazon:2330033117" ],
"latest_revision": 5,
"revision": 5,
"created": {
"type": "/type/datetime",
"value": "2016-04-22T11:47:01.838591"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-02-02T01:19:11.921173"
}
}

@ -0,0 +1,23 @@
{
"publishers": [ "Editions Gallimard" ],
"source_records": [ "amazon:2070793109" ],
"title": "La m\u00e9nagerie de papier",
"identifiers": { "amazon": [ "2070793109" ] },
"isbn_13": [ "9782070793105" ],
"covers": [ 8750266 ],
"created": {
"type": "/type/datetime",
"value": "2019-08-05T10:36:44.503432"
},
"physical_format": "mass market paperback",
"isbn_10": [ "2070793109" ],
"latest_revision": 1,
"key": "/books/OL27258011M",
"last_modified": {
"type": "/type/datetime",
"value": "2019-08-05T10:36:44.503432"
},
"works": [ { "key": "/works/OL20078005W" } ],
"type": { "key": "/type/edition" },
"revision": 1
}

@ -0,0 +1,38 @@
{
"publishers": [ "Le B\u00e9lial'" ],
"subtitle": "Terra Ignota volume 2",
"covers": [ 9376451 ],
"physical_format": "paperback",
"full_title": "Sept redditions : Terra Ignota volume 2",
"key": "/books/OL27989051M",
"authors": [ { "key": "/authors/OL7475792A" } ],
"source_records": [ "amazon:2843449626" ],
"title": "Sept redditions",
"notes": "Source title: Sept redditions: Terra Ignota volume 2 (Roman)",
"number_of_pages": 544,
"publish_date": "May 28, 2020",
"works": [ { "key": "/works/OL19213555W" } ],
"type": { "key": "/type/edition" },
"identifiers": {},
"isbn_10": [ "2843449626" ],
"isbn_13": [ "9782843449628" ],
"classifications": {},
"languages": [ { "key": "/languages/fre" } ],
"contributors": [
{
"name": "Michelle Charrier",
"role": "Translator"
}
],
"series": [ "Terra Ignota #2" ],
"latest_revision": 4,
"revision": 4,
"created": {
"type": "/type/datetime",
"value": "2020-05-02T22:25:18.922926"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-12-07T07:10:56.070304"
}
}

@ -0,0 +1 @@
{"publishers": ["GALLIMARD"], "last_modified": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "source_records": ["amazon:2070469875"], "title": "La trilogie Spin", "notes": {"type": "/type/text", "value": "Source title: La trilogie Spin (Folio SF - XL) (French Edition)"}, "number_of_pages": 1120, "isbn_13": ["9782070469871"], "covers": [10218906], "created": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "physical_format": "paperback", "isbn_10": ["2070469875"], "publish_date": "Jun 02, 2016", "key": "/books/OL28294024M", "authors": [{"key": "/authors/OL7876839A"}, {"key": "/authors/OL3113900A"}], "latest_revision": 1, "works": [{"key": "/works/OL20889233W"}], "type": {"key": "/type/edition"}, "revision": 1}

@ -0,0 +1,32 @@
{
"publishers": [ "Pocket", "POCKET" ],
"source_records": [ "amazon:2266235818" ],
"title": "Le Cycle de Dune Tome 2/Le Messie de Dune",
"notes": {
"type": "/type/text",
"value": "Source title: Le Cycle de Dune Tome 2/Le Messie de Dune (Science-fiction) (French Edition)"
},
"number_of_pages": 336,
"isbn_13": [ "9782266235815" ],
"covers": [ 10328275 ],
"physical_format": "mass market paperback",
"isbn_10": [ "2266235818" ],
"publish_date": "Nov 22, 2012",
"key": "/books/OL28639494M",
"authors": [
{ "key": "/authors/OL79034A" },
{ "key": "/authors/OL1846639A" }
],
"works": [ { "key": "/works/OL893526W" } ],
"type": { "key": "/type/edition" },
"latest_revision": 3,
"revision": 3,
"created": {
"type": "/type/datetime",
"value": "2020-08-05T18:59:33.402965"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-10-24T22:27:33.839388"
}
}

@ -0,0 +1,31 @@
{
"identifiers": { "wikidata": [ "Q81118625" ] },
"title": "Trop semblable \u00e0 l'\u00e9clair",
"publish_date": "2019",
"publishers": [ "Le B\u00e9lial'" ],
"type": { "key": "/type/edition" },
"isbn_13": [ "9782843449581" ],
"series": [ "Terra Ignota #1" ],
"physical_format": "paperback",
"contributors": [
{
"name": "Michelle Charrier",
"role": "Translator"
}
],
"languages": [ { "key": "/languages/fre" } ],
"key": "/books/OL35698073M",
"number_of_pages": 672,
"works": [ { "key": "/works/OL19800093W" } ],
"source_records": [ "amazon:2843449588" ],
"latest_revision": 4,
"revision": 4,
"created": {
"type": "/type/datetime",
"value": "2021-12-07T02:12:00.907076"
},
"last_modified": {
"type": "/type/datetime",
"value": "2022-11-15T15:47:17.497202"
}
}

@ -0,0 +1,32 @@
{
"works": [ { "key": "/works/OL19635836W" } ],
"title": "La Volont\u00e9 de se battre",
"publishers": [ "Le B\u00e9lial'" ],
"publish_date": "2020",
"key": "/books/OL35698083M",
"type": { "key": "/type/edition" },
"identifiers": {},
"covers": [ 12392970 ],
"isbn_13": [ "9782843449758" ],
"classifications": {},
"languages": [ { "key": "/languages/fre" } ],
"contributors": [
{
"name": "Michelle Charrier",
"role": "Translator"
}
],
"number_of_pages": 526,
"series": [ "Terra Ignota #3" ],
"physical_format": "paperback",
"latest_revision": 3,
"revision": 3,
"created": {
"type": "/type/datetime",
"value": "2021-12-07T02:23:07.593997"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-12-07T02:24:57.135563"
}
}

@ -0,0 +1,26 @@
{
"type": { "key": "/type/edition" },
"title": "La Zone du Dehors",
"authors": [ { "key": "/authors/OL3980331A" } ],
"publish_date": "Feb 04, 2021",
"source_records": [ "amazon:2072927528" ],
"number_of_pages": 656,
"publishers": [ "FOLIO", "GALLIMARD" ],
"isbn_10": [ "2072927528" ],
"isbn_13": [ "9782072927522" ],
"physical_format": "pocket book",
"full_title": "La Zone du Dehors",
"covers": [ 12393645 ],
"works": [ { "key": "/works/OL19960903W" } ],
"key": "/books/OL35699439M",
"latest_revision": 1,
"revision": 1,
"created": {
"type": "/type/datetime",
"value": "2021-12-07T22:26:13.534930"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-12-07T22:26:13.534930"
}
}

@ -0,0 +1,31 @@
{
"type": { "key": "/type/edition" },
"title": "Dune - tome 1",
"authors": [
{ "key": "/authors/OL9956442A" },
{ "key": "/authors/OL1846639A" }
],
"publish_date": "Nov 22, 2012",
"source_records": [ "amazon:2266233203" ],
"number_of_pages": 832,
"publishers": [ "POCKET", "Pocket" ],
"isbn_10": [ "2266233203" ],
"isbn_13": [ "9782266233200" ],
"physical_format": "pocket book",
"notes": {
"type": "/type/text",
"value": "Source title: Dune - tome 1 (1)"
},
"works": [ { "key": "/works/OL27962193W" } ],
"key": "/books/OL38218739M",
"latest_revision": 1,
"revision": 1,
"created": {
"type": "/type/datetime",
"value": "2022-05-30T17:18:00.228322"
},
"last_modified": {
"type": "/type/datetime",
"value": "2022-05-30T17:18:00.228322"
}
}

@ -0,0 +1,28 @@
{
"type": { "key": "/type/edition" },
"title": "Total Recall et autres r\u00e9cits",
"authors": [
{ "key": "/authors/OL274606A" },
{ "key": "/authors/OL3113922A" }
],
"publish_date": "Jul 12, 2012",
"source_records": [ "amazon:2070448908" ],
"number_of_pages": 448,
"publishers": [ "FOLIO", "GALLIMARD" ],
"isbn_10": [ "2070448908" ],
"isbn_13": [ "9782070448906" ],
"physical_format": "pocket book",
"works": [ { "key": "/works/OL28185064W" } ],
"key": "/books/OL38586212M",
"covers": [ 13858141 ],
"latest_revision": 3,
"revision": 3,
"created": {
"type": "/type/datetime",
"value": "2022-07-10T01:29:29.296699"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-04-07T22:44:13.567567"
}
}

@ -0,0 +1,13 @@
{
"summary": {
"average": null,
"count": 0
},
"counts": {
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0
}
}

@ -0,0 +1 @@
{"summary": {"average": 4.333333333333333, "count": 6, "sortable": 3.114900291576932}, "counts": {"1": 0, "2": 0, "3": 1, "4": 2, "5": 3}}

@ -0,0 +1,14 @@
{
"summary": {
"average": 4.8,
"count": 5,
"sortable": 3.216059213089321
},
"counts": {
"1": 0,
"2": 0,
"3": 0,
"4": 1,
"5": 4
}
}

@ -0,0 +1 @@
{"summary": {"average": 3.6923076923076925, "count": 13, "sortable": 2.9048164811987554}, "counts": {"1": 2, "2": 2, "3": 1, "4": 1, "5": 7}}

@ -0,0 +1,14 @@
{
"summary": {
"average": 4.0,
"count": 1,
"sortable": 2.3286737413641063
},
"counts": {
"1": 0,
"2": 0,
"3": 0,
"4": 1,
"5": 0
}
}

@ -0,0 +1 @@
{"summary": {"average": null, "count": 0}, "counts": {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0}}

@ -0,0 +1 @@
{"summary": {"average": null, "count": 0}, "counts": {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0}}

@ -0,0 +1,14 @@
{
"summary": {
"average": 3.0,
"count": 1,
"sortable": 2.19488243981746
},
"counts": {
"1": 0,
"2": 0,
"3": 1,
"4": 0,
"5": 0
}
}

@ -0,0 +1,13 @@
{
"summary": {
"average": null,
"count": 0
},
"counts": {
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0
}
}

@ -0,0 +1 @@
{"summary": {"average": 3.9368421052631577, "count": 95, "sortable": 3.721132697535656}, "counts": {"1": 3, "2": 4, "3": 19, "4": 39, "5": 30}}

@ -0,0 +1,22 @@
{
"title": "L'\u00c9veil du L\u00e9viathan",
"key": "/works/OL17334140W",
"authors": [
{
"type": { "key": "/type/author_role" },
"author": { "key": "/authors/OL6982995A" }
}
],
"type": { "key": "/type/work" },
"covers": [ 7412481 ],
"latest_revision": 3,
"revision": 3,
"created": {
"type": "/type/datetime",
"value": "2016-04-22T11:47:01.838591"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-02-02T01:19:11.921173"
}
}

@ -0,0 +1 @@
{"description": "\"It is a world in which near-instantaneous travel from continent to continent is free to all. In which automation now provides for everybody's basic needs. In which nobody living can remember an actual war. In which it is illegal for three or more people to gather for the practice of religion--but ecumenical \"sensayers\" minister in private, one-on-one. In which gendered language is archaic, and to dress as strongly male or female is, if not exactly illegal, deeply taboo. In which nationality is a fading memory, and most people identify instead with their choice of the seven global Hives, distinguished from one another by their different approaches to the big questions of life. And it is a world in which, unknown to most, the entire social order is teetering on the edge of collapse. Because even in utopia, humans will conspire. And also because something new has arisen: Bridger, the child who can bring inanimate objects to conscious life\"--", "covers": [8429595, 8772829, 9338105, 9376451], "key": "/works/OL19213555W", "authors": [{"author": {"key": "/authors/OL7475792A"}, "type": {"key": "/type/author_role"}}], "title": "Seven Surrenders", "subjects": ["Utopias", "Fiction", "Fiction, science fiction, general", "series:terra_ignota"], "type": {"key": "/type/work"}, "latest_revision": 6, "revision": 6, "created": {"type": "/type/datetime", "value": "2019-03-11T19:38:25.579004"}, "last_modified": {"type": "/type/datetime", "value": "2021-12-07T07:10:56.070304"}}

@ -0,0 +1,24 @@
{
"description": "\"The long years of near-utopia have come to an abrupt end. Peace and order are now figments of the past. Corruption, deception, and insurgency hum within the once steadfast leadership of the Hives, nations without fixed location. The heartbreaking truth is that for decades, even centuries, the leaders of the great Hives bought the world's stability with a trickle of secret murders, mathematically planned. So that no faction could ever dominate. So that the balance held. The Hives' fa\u00e7ade of solidity is the only hope they have for maintaining a semblance of order, for preventing the public from succumbing to the savagery and bloodlust of wars past. But as the great secret becomes more and more widely known, that fa\u00e7ade is slipping away. Just days earlier, the world was a pinnacle of human civilization. Now everyone--Hives and hiveless, Utopians and sensayers, emperors and the downtrodden, warriors and saints--scrambles to prepare for the seemingly inevitable war\"--",
"covers": [ 8544084, 8619055, 10180814 ],
"key": "/works/OL19635836W",
"authors": [
{
"author": { "key": "/authors/OL7475792A" },
"type": { "key": "/type/author_role" }
}
],
"title": "The Will to Battle",
"subjects": [ "Utopias", "Fiction", "Fiction, science fiction, general", "series:terra_ignota" ],
"type": { "key": "/type/work" },
"latest_revision": 7,
"revision": 7,
"created": {
"type": "/type/datetime",
"value": "2019-04-21T08:07:12.674468"
},
"last_modified": {
"type": "/type/datetime",
"value": "2021-12-07T07:08:28.885088"
}
}

@ -0,0 +1 @@
{"description": "\"The world into which Mycroft and Carlyle have been born is as strange to our 21st-century eyes as ours would be to a native of the 1500s. It is a hard-won utopia built on technologically-generated abundance, and also on complex and mandatory systems of labeling all public writing and speech... And in this world, Mycroft and Carlyle have stumbled on the wild card that may destabilize the system: the boy Bridger, who can effortlessly make his wishes come true. Who can, it would seem, bring inanimate objects to life...\"--Book jacket.", "covers": [8600692, 8673756], "key": "/works/OL19800093W", "authors": [{"author": {"key": "/authors/OL7475792A"}, "type": {"key": "/type/author_role"}}], "title": "Too Like the Lightning", "subjects": ["Utopias", "Prisoners", "Twenty-fifth century", "Fiction", "Third millennium", "Fiction, science fiction, general", "series:terra_ignota", "Spirituality", "Magic", "FICTION", "Science Fiction"], "type": {"key": "/type/work"}, "latest_revision": 6, "revision": 6, "created": {"type": "/type/datetime", "value": "2019-06-23T20:50:30.749828"}, "last_modified": {"type": "/type/datetime", "value": "2022-03-12T06:35:56.153258"}}

@ -0,0 +1,22 @@
{
"title": "La zone du dehors",
"key": "/works/OL19960903W",
"authors": [
{
"type": { "key": "/type/author_role" },
"author": { "key": "/authors/OL3980331A" }
}
],
"type": { "key": "/type/work" },
"covers": [ 13472433 ],
"latest_revision": 2,
"revision": 2,
"created": {
"type": "/type/datetime",
"value": "2019-07-17T23:01:16.580404"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-03-15T21:59:10.897047"
}
}

@ -0,0 +1,16 @@
{
"title": "La m\u00e9nagerie de papier",
"created": {
"type": "/type/datetime",
"value": "2019-08-05T10:36:44.503432"
},
"covers": [ 8750266 ],
"last_modified": {
"type": "/type/datetime",
"value": "2019-08-05T10:36:44.503432"
},
"latest_revision": 1,
"key": "/works/OL20078005W",
"type": { "key": "/type/work" },
"revision": 1
}

@ -0,0 +1 @@
{"title": "La trilogie Spin", "created": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "covers": [10218906], "last_modified": {"type": "/type/datetime", "value": "2020-06-28T05:17:49.626242"}, "latest_revision": 1, "key": "/works/OL20889233W", "authors": [{"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL7876839A"}}, {"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL3113900A"}}], "type": {"key": "/type/work"}, "revision": 1}

@ -0,0 +1,26 @@
{
"type": { "key": "/type/work" },
"title": "Dune - tome 1",
"authors": [
{
"type": { "key": "/type/author_role" },
"author": { "key": "/authors/OL9956442A" }
},
{
"type": { "key": "/type/author_role" },
"author": { "key": "/authors/OL1846639A" }
}
],
"key": "/works/OL27962193W",
"covers": [ 13823878 ],
"latest_revision": 2,
"revision": 2,
"created": {
"type": "/type/datetime",
"value": "2022-05-30T17:18:00.228322"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-04-04T09:05:11.531979"
}
}

@ -0,0 +1,26 @@
{
"type": { "key": "/type/work" },
"title": "Total Recall et autres r\u00e9cits",
"authors": [
{
"type": { "key": "/type/author_role" },
"author": { "key": "/authors/OL274606A" }
},
{
"type": { "key": "/type/author_role" },
"author": { "key": "/authors/OL3113922A" }
}
],
"key": "/works/OL28185064W",
"covers": [ 13858141 ],
"latest_revision": 3,
"revision": 3,
"created": {
"type": "/type/datetime",
"value": "2022-07-10T01:29:29.296699"
},
"last_modified": {
"type": "/type/datetime",
"value": "2023-04-07T22:44:13.567567"
}
}

@ -0,0 +1 @@
{"subjects": ["American Science fiction", "Dune (Imaginary place)", "Fiction", "Fiction in English", "Imaginary places", "Science Fiction", "Translations into Russian", "Novela", "Dune (Lugar imaginario)", "Lectures et morceaux choisis", "Anglais (langue)", "Roman ame ricain", "Science-fiction ame ricaine", "Long Now Manual for Civilization", "Roman ame\u0301ricain", "Science-fiction ame\u0301ricaine", "Dune (imaginary place), fiction", "Fiction, science fiction, general"], "key": "/works/OL893526W", "title": "Dune Messiah", "authors": [{"author": {"key": "/authors/OL79034A"}, "type": {"key": "/type/author_role"}}, {"author": {"key": "/authors/OL1846639A"}, "type": {"key": "/type/author_role"}}], "type": {"key": "/type/work"}, "covers": [2421405, 1009421, 5277575, 284503, 8450071, 8771464, 10328275, 11422534, 11290920, 10849793, 979507, 8376882], "description": {"type": "/type/text", "value": "Bearbeitete Neuausgabe"}, "latest_revision": 18, "revision": 18, "created": {"type": "/type/datetime", "value": "2009-12-09T06:52:50.872607"}, "last_modified": {"type": "/type/datetime", "value": "2023-01-31T17:11:49.536060"}}

@ -0,0 +1,126 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\MyLibraryDB\MyLibraryDB.csproj" />
<ProjectReference Include="..\..\MyLibraryEntities\MyLibraryEntities.csproj" />
<ProjectReference Include="..\..\StubbedDB\StubbedDB.csproj" />
<ProjectReference Include="..\..\StubbedDTO\StubbedDTO.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<None Remove="authors\" />
<None Remove="books\" />
<None Remove="ratings\" />
<None Remove="works\" />
</ItemGroup>
<ItemGroup>
<None Update="authors\OL1846639A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="authors\OL274606A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="authors\OL3113922A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="authors\OL3980331A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="authors\OL6982995A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="authors\OL7475792A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="authors\OL9956442A.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="books\OL25910297M.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="books\OL35698083M.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="books\OL35699439M.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="books\OL38218739M.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="books\OL38586212M.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="ratings\OL17334140W.ratings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="ratings\OL19635836W.ratings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="ratings\OL19960903W.ratings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="ratings\OL27962193W.ratings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="ratings\OL28185064W.ratings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="works\OL17334140W.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="works\OL19635836W.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="works\OL19960903W.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="works\OL27962193W.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="works\OL28185064W.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="authors\" />
<Folder Include="books\" />
<Folder Include="ratings\" />
<Folder Include="works\" />
</ItemGroup>
</Project>

@ -0,0 +1,19 @@
// See https://aka.ms/new-console-template for more information
using Microsoft.EntityFrameworkCore;
using MyLibraryDB;
using StubbedDB;
//StubbedDTO.Stub.BasePath = Directory.GetCurrentDirectory();
using (var context = new MyLibraryStubbedContext())
{
foreach(var a in context.Authors.Include(auth => auth.Works))
{
Console.WriteLine($"{a.Id} - {a.Name} (Works count: {a.Works.Count})");
}
foreach(var b in context.Books.Include(book => book.Authors))
{
Console.WriteLine($"{b.Id} - {b.Title} (Authors count: {b.Authors.Count})");
}
}

@ -0,0 +1,80 @@
using DtoAbstractLayer;
using LibraryDTO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using OpenLibraryClient;
using OpenLibraryWrapper.Controllers;
using StubbedDTO;
namespace OpenLibraryWrapper_UT;
public class BookController_UT
{
private readonly BookController controller;
private readonly IDtoManager dtoManager = new Stub();
public BookController_UT()
{
var logger = new NullLogger<BookController>();
controller = new BookController(logger, dtoManager);
}
[Theory]
[InlineData(true, "L'\u00c9veil du L\u00e9viathan", "9782330033118")]
[InlineData(false, null, "1782330033118")]
public async void TestGetBookByIsbn(bool expectedResult, string expectedTitle, string isbn)
{
var result = await controller.GetBookByIsbn(isbn);
Assert.Equal(expectedResult, result is OkObjectResult);
if(result is not OkObjectResult)
{
return;
}
var okResult = result as OkObjectResult;
var bookDto = okResult.Value as BookDTO;
Assert.Equal(expectedTitle, bookDto.Title);
}
[Theory]
[InlineData(true, "L'\u00c9veil du L\u00e9viathan", "OL25910297M")]
[InlineData(false, null, "OL25910xxxM")]
public async void TestGetBookById(bool expectedResult, string expectedTitle, string id)
{
var result = await controller.GetBookById(id);
Assert.Equal(expectedResult, result is OkObjectResult);
if(result is not OkObjectResult)
{
return;
}
var okResult = result as OkObjectResult;
var bookDto = okResult.Value as BookDTO;
Assert.Equal(expectedTitle, bookDto.Title);
}
[Fact]
public async void TestGetBooksByTitle()
{
var result = await controller.GetBooksByTitle("ne", 0, 5);
var okResult = result as OkObjectResult;
var booksTupple = (Tuple<long, IEnumerable<BookDTO>>)okResult.Value;
long nbBooks = booksTupple.Item1;
var books = booksTupple.Item2;
Assert.True(nbBooks > 0);
}
[Fact]
public async void TestGetBooksByAuthor()
{
var result = await controller.GetBooksByAuthor("al", 0, 5);
var okResult = result as OkObjectResult;
var booksTupple = (Tuple<long, IEnumerable<BookDTO>>)okResult.Value;
long nbBooks = booksTupple.Item1;
var books = booksTupple.Item2;
Assert.Equal(4, books.Count());
}
}

@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\StubbedDTO\StubbedDTO.csproj" />
<ProjectReference Include="..\..\DtoAbstractLayer\DtoAbstractLayer.csproj" />
<ProjectReference Include="..\..\LibraryDTO\LibraryDTO.csproj" />
<ProjectReference Include="..\..\OpenLibraryClient\OpenLibraryClient.csproj" />
<ProjectReference Include="..\..\OpenLibraryWrapper\OpenLibraryWrapper.csproj" />
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

Loading…
Cancel
Save