Add repository pattern and Automapper nuggetpull/1/head
parent
90dab5667b
commit
6d234a65bd
@ -0,0 +1,734 @@
|
|||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/csharp,rider,intellij+all,visualstudio,visualstudiocode
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=csharp,rider,intellij+all,visualstudio,visualstudiocode
|
||||||
|
|
||||||
|
### Csharp ###
|
||||||
|
## 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
### Intellij+all ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### Intellij+all Patch ###
|
||||||
|
# Ignore everything but code style settings and run configurations
|
||||||
|
# that are supposed to be shared within teams.
|
||||||
|
|
||||||
|
.idea/*
|
||||||
|
|
||||||
|
!.idea/codeStyles
|
||||||
|
!.idea/runConfigurations
|
||||||
|
|
||||||
|
### Rider ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
### VisualStudio ###
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
|
||||||
|
# Others
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
|
||||||
|
### VisualStudio Patch ###
|
||||||
|
# Additional files built by Visual Studio
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/csharp,rider,intellij+all,visualstudio,visualstudiocode
|
@ -1,4 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=711b0308_002Dc8c6_002D4423_002Db315_002D82f61e82bdb5/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="alumniTest" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
|
||||||
<Solution />
|
|
||||||
</SessionState></s:String></wpf:ResourceDictionary>
|
|
@ -0,0 +1,26 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
using Infrastructure.Base;
|
||||||
|
using Shared;
|
||||||
|
|
||||||
|
namespace Infrastructure;
|
||||||
|
|
||||||
|
public interface IRepository<T> where T : EntityBase
|
||||||
|
{
|
||||||
|
IEnumerable<T> GetAll(params Expression<Func<T, object>>[] includes);
|
||||||
|
|
||||||
|
Task<IEnumerable<T>> GetAllAsync(Expression<Func<T, bool>>? expression = null, CancellationToken cancellationToken = default, params Expression<Func<T, object>>[] includes);
|
||||||
|
|
||||||
|
Task<T?> GetByIdAsync(object id, params Expression<Func<T, object>>[] includes);
|
||||||
|
|
||||||
|
Task InsertAsync(T obj);
|
||||||
|
|
||||||
|
void Update(T obj);
|
||||||
|
|
||||||
|
void Delete(object id);
|
||||||
|
|
||||||
|
Task<PaginatedResult<T>> GetPaginatedListAsync(int pageNumber, int pageSize, string[]? orderBy = null, Expression<Func<T, bool>>? expression = null, CancellationToken cancellationToken = default, params Expression<Func<T, object>>[] includes);
|
||||||
|
|
||||||
|
Task<int> CountAsync(Expression<Func<T, bool>>? expression = null, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
Task<bool> ExistsAsync(Expression<Func<T, bool>> expression, CancellationToken cancellationToken = default);
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace Infrastructure;
|
||||||
|
|
||||||
|
public interface IUnitOfWork
|
||||||
|
{
|
||||||
|
Task SaveAsync();
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
using Infrastructure.Base;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Shared;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq.Dynamic.Core;
|
||||||
|
|
||||||
|
namespace Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class GenericRepository<T> : IRepository<T> where T : EntityBase
|
||||||
|
{
|
||||||
|
protected readonly OptifitDbContext context;
|
||||||
|
|
||||||
|
public GenericRepository(OptifitDbContext context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> GetAll(params Expression<Func<T, object>>[] includes)
|
||||||
|
{
|
||||||
|
IQueryable<T> query = this.context.Set<T>();
|
||||||
|
|
||||||
|
query = includes.Aggregate(query, (current, include) => current.Include(include));
|
||||||
|
|
||||||
|
return query.ToList<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<T>> GetAllAsync(Expression<Func<T, bool>>? expression = null, CancellationToken cancellationToken = default, params Expression<Func<T, object>>[] includes)
|
||||||
|
{
|
||||||
|
IQueryable<T> query = this.context.Set<T>();
|
||||||
|
query = includes.Aggregate(query, (current, include) => current.Include(include));
|
||||||
|
if (expression != null) query = query.Where(expression);
|
||||||
|
|
||||||
|
return await query.ToDynamicListAsync<T>(cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async Task<T?> GetByIdAsync(object id, params Expression<Func<T, object>>[] includes)
|
||||||
|
{
|
||||||
|
IQueryable<T> query = this.context.Set<T>();
|
||||||
|
|
||||||
|
query = query.Where(entity => entity.Id.Equals(id));
|
||||||
|
|
||||||
|
query = includes.Aggregate(query, (current, include) => current.Include(include));
|
||||||
|
|
||||||
|
return await query.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task InsertAsync(T obj)
|
||||||
|
{
|
||||||
|
_ = await this.context.Set<T>()
|
||||||
|
.AddAsync(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(T obj)
|
||||||
|
{
|
||||||
|
_ = this.context.Set<T>().Attach(obj);
|
||||||
|
this.context.Entry(obj).State = EntityState.Modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(object id)
|
||||||
|
{
|
||||||
|
var existing = this.context
|
||||||
|
.Set<T>()
|
||||||
|
.Find(id);
|
||||||
|
|
||||||
|
_ = this.context.Set<T>().Remove(existing!);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PaginatedResult<T>> GetPaginatedListAsync(
|
||||||
|
int pageNumber,
|
||||||
|
int pageSize,
|
||||||
|
string[]? orderBy = null,
|
||||||
|
Expression<Func<T, bool>>? expression = null,
|
||||||
|
CancellationToken cancellationToken = default,
|
||||||
|
params Expression<Func<T, object>>[] includes)
|
||||||
|
{
|
||||||
|
IQueryable<T> query = this.context.Set<T>();
|
||||||
|
|
||||||
|
query = includes.Aggregate(query, (current, include) => current.Include(include));
|
||||||
|
|
||||||
|
if (expression != null) query = query.Where(expression);
|
||||||
|
|
||||||
|
var ordering = orderBy?.Any() == true ? string.Join(",", orderBy) : null;
|
||||||
|
|
||||||
|
query = !string.IsNullOrWhiteSpace(ordering) ? query.OrderBy(ordering) : query.OrderBy(a => a.Id);
|
||||||
|
|
||||||
|
var count = await query
|
||||||
|
.AsNoTracking()
|
||||||
|
.CountAsync(cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
var items = await query
|
||||||
|
.Skip(pageNumber * pageSize)
|
||||||
|
.Take(pageSize)
|
||||||
|
.ToDynamicListAsync<T>(cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
return new PaginatedResult<T>(items, count, pageNumber, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> CountAsync(Expression<Func<T, bool>>? expression = null, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
IQueryable<T> query = this.context.Set<T>();
|
||||||
|
if (expression != null) query = query.Where(expression);
|
||||||
|
|
||||||
|
return await query
|
||||||
|
.AsNoTracking()
|
||||||
|
.CountAsync(cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> ExistsAsync(Expression<Func<T, bool>> expression, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return await this.context.Set<T>().AnyAsync(expression, cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
using Infrastructure.Entities;
|
||||||
|
|
||||||
|
namespace Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public interface IUserRepository : IRepository<User>
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
using Infrastructure.Entities;
|
||||||
|
|
||||||
|
namespace Infrastructure.Repositories;
|
||||||
|
|
||||||
|
public class UserRepository : GenericRepository<User>, IUserRepository
|
||||||
|
{
|
||||||
|
public UserRepository(OptifitDbContext context) : base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ActiveDebugProfile>https</ActiveDebugProfile>
|
|
||||||
<Controller_SelectedScaffolderID>MinimalApiScaffolder</Controller_SelectedScaffolderID>
|
|
||||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
|
||||||
<WebStackScaffolding_ControllerDialogWidth>650</WebStackScaffolding_ControllerDialogWidth>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
@ -1,45 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Asp.Versioning;
|
|
||||||
using Server.IServices;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.Controller.v1;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[ApiVersion("1.0")]
|
|
||||||
[Route("api/v{version:apiVersion}/alumni-restricted")]
|
|
||||||
public class AlumniRestrictedController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ILogger<AlumniRestrictedController> _logger;
|
|
||||||
private IAlumnisService _dataServices;
|
|
||||||
|
|
||||||
public AlumniRestrictedController(ILogger<AlumniRestrictedController> logger, IAlumnisService dataServices)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_dataServices = dataServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(typeof(IEnumerable<ResponseAlumniDto>), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
||||||
[RequireHttps]
|
|
||||||
public async Task<IActionResult> GetAlumniRestricted([FromQuery] string? lastname, [FromQuery] int page = 1, [FromQuery] int size = 5,
|
|
||||||
[FromQuery] AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None, [FromQuery] bool ascending = true)
|
|
||||||
{
|
|
||||||
var alumni = await _dataServices.GetAlumnisRestricted(lastname, page, size, orderCriteria, ascending);
|
|
||||||
if( alumni.Count == 0) return NoContent();
|
|
||||||
return Ok(alumni.Alumnis);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
[ProducesResponseType(typeof(ResponseAlumniDto), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[RequireHttps]
|
|
||||||
public IActionResult GetAlumniRestrictedById(string id)
|
|
||||||
{
|
|
||||||
var alumni = _dataServices.GetAlumniRestrictedById(id);
|
|
||||||
return alumni.Result == null ? NotFound() : Ok(alumni.Result);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Asp.Versioning;
|
|
||||||
using Server.IServices;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.Controller.v1;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[ApiVersion("1.0")]
|
|
||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
|
||||||
public class AlumnisController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ILogger<AlumnisController> _logger;
|
|
||||||
private IAlumnisService _dataServices;
|
|
||||||
|
|
||||||
public AlumnisController(ILogger<AlumnisController> logger, IAlumnisService dataServices)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_dataServices = dataServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
[ProducesResponseType(typeof(IEnumerable<ResponseAlumniDto>), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
||||||
[RequireHttps]
|
|
||||||
public IActionResult GetAlumni([FromQuery] string? lastname, [FromQuery] int page = 1, [FromQuery] int size = 5,
|
|
||||||
[FromQuery] AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None, [FromQuery] bool ascending = true)
|
|
||||||
{
|
|
||||||
var alumni = _dataServices.GetAlumnis(lastname, page, size, orderCriteria, ascending);
|
|
||||||
return alumni.Result.Count == 0 ? NoContent() : Ok(alumni.Result.Alumnis);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[HttpPost()]
|
|
||||||
[ProducesResponseType(typeof(ResponseAlumniDto), StatusCodes.Status201Created)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[RequireHttps]
|
|
||||||
public IActionResult CreateAlumni([FromBody] RequestAlumniDto alumniDto)
|
|
||||||
{
|
|
||||||
var alumni = _dataServices.CreateAlumni(alumniDto);
|
|
||||||
return alumni.Result == null ? BadRequest() : CreatedAtAction(nameof(CreateAlumni), alumni);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
[ProducesResponseType(typeof(ResponseAlumniDto), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
|
|
||||||
[RequireHttps]
|
|
||||||
public IActionResult GetAlumniById(string id)
|
|
||||||
{
|
|
||||||
var alumni = _dataServices.GetAlumniById(id);
|
|
||||||
return alumni.Result == null ? NotFound() : Ok(alumni);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,45 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Server.Dto.Request;
|
||||||
|
using Server.Dto.Response;
|
||||||
|
using Asp.Versioning;
|
||||||
|
using Server.IServices;
|
||||||
|
|
||||||
|
namespace Server.Controller.v1;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
|
public class UsersController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<UsersController> _logger;
|
||||||
|
private IUsersService _dataServices;
|
||||||
|
|
||||||
|
public UsersController(ILogger<UsersController> logger, IUsersService dataServices)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_dataServices = dataServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<ResponseUserDto>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[RequireHttps]
|
||||||
|
public IActionResult GetUsers([FromQuery] int pageIndex = 1, [FromQuery] int pageSize = 5, [FromQuery] bool ascending = true)
|
||||||
|
{
|
||||||
|
var users = _dataServices.GetUsers(pageIndex, pageSize, ascending);
|
||||||
|
return users.Result.TotalCount == 0 ? NoContent() : Ok(users);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
[ProducesResponseType(typeof(ResponseUserDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
|
||||||
|
[RequireHttps]
|
||||||
|
public IActionResult GetAlumniById(string id)
|
||||||
|
{
|
||||||
|
var alumni = _dataServices.GetUserById(id);
|
||||||
|
return alumni.Result == null ? NotFound() : Ok(alumni);
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Server.Dto.Request;
|
|
||||||
|
|
||||||
public class RequestAlumniDto
|
|
||||||
{
|
|
||||||
[EmailAddress(ErrorMessage = "Invalid Email")]
|
|
||||||
[Required(ErrorMessage = "Email is required")]
|
|
||||||
public string Email { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Password is required")]
|
|
||||||
public string Password { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "EntryYear is required")]
|
|
||||||
public string EntryYear { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "FirstName is required")]
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "LastName is required")]
|
|
||||||
public string LastName { get; set; }
|
|
||||||
|
|
||||||
public string? LinkedinUrl { get; set; }
|
|
||||||
|
|
||||||
public string? GithubUrl { get; set; }
|
|
||||||
|
|
||||||
public string? PortfolioUrl { get; set; }
|
|
||||||
|
|
||||||
public string? ImageUrl { get; set; }
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Server.Dto.Request;
|
|
||||||
|
|
||||||
public class RequestEventDto
|
|
||||||
{
|
|
||||||
[Required(ErrorMessage = "AlumniId is required")]
|
|
||||||
public string AlumniId { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Title is required")]
|
|
||||||
public string Title { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Description is required")]
|
|
||||||
public string Description { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Date is required")]
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "NumberOfParticipants is required")]
|
|
||||||
public int nbMaxRegistrations { get; set; }
|
|
||||||
|
|
||||||
public string? ImageUrl { get; set; }
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Server.Dto.Request;
|
|
||||||
|
|
||||||
public class RequestExperienceDto
|
|
||||||
{
|
|
||||||
[Required(ErrorMessage = "AlumniId is required")]
|
|
||||||
public string AlumniId { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Title of post is required")]
|
|
||||||
public string Title { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "StartingDate is required")]
|
|
||||||
public DateTime StartingDate { get; set; }
|
|
||||||
|
|
||||||
public DateTime? EndingDate { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Company's name is required")]
|
|
||||||
public string CompanyName { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "CurrentFormation is required")]
|
|
||||||
public bool CurrentJob { get; set; }
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Server.Dto.Request;
|
|
||||||
|
|
||||||
public class RequestFormationDto
|
|
||||||
{
|
|
||||||
[Required(ErrorMessage = "AlumniId is required")]
|
|
||||||
public string AlumniId { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "Name of formation is required")]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "StartingDate is required")]
|
|
||||||
public DateTime StartingDate { get; set; }
|
|
||||||
|
|
||||||
public DateTime? EndingDate { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "School's name is required")]
|
|
||||||
public string SchoolName { get; set; }
|
|
||||||
|
|
||||||
[Required(ErrorMessage = "CurrentFormation is required")]
|
|
||||||
public bool CurrentFormation { get; set; }
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Server.Dto.Request;
|
||||||
|
|
||||||
|
public class RequestUserDto
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "FirstName is required")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
using Shared.Enums;
|
|
||||||
|
|
||||||
namespace Server.Dto.Response;
|
|
||||||
|
|
||||||
public class ResponseAlumniDto
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string Email { get; set; }
|
|
||||||
public ERole ERole { get; set; }
|
|
||||||
public string EntryYear { get; set; }
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
public string? LinkedinUrl { get; set; }
|
|
||||||
public string? GithubUrl { get; set; }
|
|
||||||
public string? PortfolioUrl { get; set; }
|
|
||||||
public string? ImageUrl { get; set; }
|
|
||||||
public IEnumerable<ResponseExperienceDto> Experiences { get; set; } = new List<ResponseExperienceDto>();
|
|
||||||
public IEnumerable<ResponseFormationDto> Formations { get; set; } = new List<ResponseFormationDto>();
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
namespace Server.Dto.Response;
|
|
||||||
|
|
||||||
public class ResponseEventDto
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string? AlumniId { get; set; }
|
|
||||||
public string Title { get; set; }
|
|
||||||
public string? ImageUrl { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
public int nbMaxRegistrations { get; set; }
|
|
||||||
public int nbRegistrations { get; set; }
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace Server.Dto.Response;
|
|
||||||
|
|
||||||
public class ResponseExperienceDto
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string? AlumniId { get; set; }
|
|
||||||
public string Title { get; set; }
|
|
||||||
public DateTime StartingDate { get; set; }
|
|
||||||
public DateTime? EndingDate { get; set; }
|
|
||||||
public string CompanyName { get; set; }
|
|
||||||
public bool CurrentJob { get; set; }
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace Server.Dto.Response;
|
|
||||||
|
|
||||||
public class ResponseFormationDto
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string? AlumniId { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public DateTime StartingDate { get; set; }
|
|
||||||
public DateTime? EndingDate { get; set; }
|
|
||||||
public string SchoolName { get; set; }
|
|
||||||
public bool CurrentFormation { get; set; }
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace Server.Dto.Response;
|
|
||||||
|
|
||||||
public class ResponseRestrictedAlumniDto
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
public string LastName { get; set; }
|
|
||||||
public string? LinkedinUrl { get; set; }
|
|
||||||
public string? ImageUrl { get; set; }
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
namespace Server.Dto.Response;
|
||||||
|
|
||||||
|
public class ResponseUserDto
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Age { get; set; }
|
||||||
|
public float Height { get; set; }
|
||||||
|
public float Weight { get; set; }
|
||||||
|
public bool Sexe { get; set; }
|
||||||
|
public string? Logo { get; set; }
|
||||||
|
public int NbSessionPerWeek { get; set; }
|
||||||
|
public string? EGoal { get; set; }
|
||||||
|
public string? ESleepLevel { get; set; }
|
||||||
|
}
|
@ -1,17 +0,0 @@
|
|||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.IServices;
|
|
||||||
|
|
||||||
public interface IAlumnisService
|
|
||||||
{
|
|
||||||
Task<(long Count, IEnumerable<ResponseRestrictedAlumniDto> Alumnis)> GetAlumnisRestricted(string? lastname, int page, int size, AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None, bool ascending = true);
|
|
||||||
Task<ResponseRestrictedAlumniDto?> GetAlumniRestrictedById(string id);
|
|
||||||
Task<ResponseAlumniDto?> GetAlumniById(string id);
|
|
||||||
Task<(long Count, IEnumerable<ResponseAlumniDto> Alumnis)> GetAlumnis
|
|
||||||
(string? lastname, int page, int size, AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None,
|
|
||||||
bool ascending = true);
|
|
||||||
|
|
||||||
Task<ResponseAlumniDto?> CreateAlumni(RequestAlumniDto alumni);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.IServices;
|
|
||||||
|
|
||||||
public interface IEventsService
|
|
||||||
{
|
|
||||||
Task<ResponseEventDto?> GetEventById(string id);
|
|
||||||
|
|
||||||
Task<(long Count, IEnumerable<ResponseEventDto> Events)> GetEvents
|
|
||||||
(string? title, int page, int size, EventOrderCriteria orderCriteria = EventOrderCriteria.Date,
|
|
||||||
bool ascending = true);
|
|
||||||
|
|
||||||
Task<ResponseEventDto?> CreateEvent(RequestEventDto evt);
|
|
||||||
Task<ResponseEventDto?> UpdateEvent(string id, RequestEventDto evt);
|
|
||||||
Task<bool> DeleteEvent(string id);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.IServices;
|
|
||||||
|
|
||||||
public interface IExperiencesService
|
|
||||||
{
|
|
||||||
Task<ResponseExperienceDto?> GetExperienceById(string id);
|
|
||||||
|
|
||||||
Task<(long Count, IEnumerable<ResponseExperienceDto> Experiences)> GetExperiences
|
|
||||||
(string? title, int page, int size,
|
|
||||||
ExperienceOrderCriteria orderCriteria = ExperienceOrderCriteria.EndDate, bool ascending = true);
|
|
||||||
|
|
||||||
Task<ResponseExperienceDto?> CreateExperience(RequestExperienceDto experience);
|
|
||||||
Task<ResponseExperienceDto?> UpdateExperience(string id, RequestExperienceDto experience);
|
|
||||||
Task<bool> DeleteExperience(string id);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.IServices;
|
|
||||||
|
|
||||||
public interface IFormationsService
|
|
||||||
{
|
|
||||||
Task<ResponseFormationDto?> GetFormationById(string id);
|
|
||||||
|
|
||||||
Task<(long Count, IEnumerable<ResponseFormationDto> Formations)> GetFormations
|
|
||||||
(string? name, int page, int size, FormationOrderCriteria orderCriteria, bool ascending = true);
|
|
||||||
|
|
||||||
Task<ResponseFormationDto?> CreateFormation(RequestFormationDto formation);
|
|
||||||
Task<ResponseFormationDto?> UpdateFormation(string id, RequestFormationDto formation);
|
|
||||||
Task<bool> DeleteFormation(string id);
|
|
||||||
}
|
|
@ -0,0 +1,12 @@
|
|||||||
|
using Infrastructure.Entities;
|
||||||
|
using Server.Dto.Request;
|
||||||
|
using Server.Dto.Response;
|
||||||
|
using Shared;
|
||||||
|
|
||||||
|
namespace Server.IServices;
|
||||||
|
|
||||||
|
public interface IUsersService
|
||||||
|
{
|
||||||
|
Task<ResponseUserDto?> GetUserById(string id);
|
||||||
|
Task<PaginatedResult<ResponseUserDto>> GetUsers(int page, int size, bool ascending = true);
|
||||||
|
}
|
@ -1,64 +0,0 @@
|
|||||||
using Infrastructure.Entities;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Shared.Enums;
|
|
||||||
|
|
||||||
namespace Server.Mappers;
|
|
||||||
|
|
||||||
public static class AlumnisMappers
|
|
||||||
{
|
|
||||||
public static ResponseAlumniDto ToDto(this User alumni)
|
|
||||||
{
|
|
||||||
return new ResponseAlumniDto
|
|
||||||
{
|
|
||||||
Id = alumni.Id,
|
|
||||||
Email = alumni.Email,
|
|
||||||
ERole = alumni.Role.ToERole(),
|
|
||||||
EntryYear = alumni.EntryYear,
|
|
||||||
FirstName = alumni.FirstName,
|
|
||||||
LastName = alumni.LastName,
|
|
||||||
LinkedinUrl = alumni.Linkedin,
|
|
||||||
GithubUrl = alumni.Github,
|
|
||||||
PortfolioUrl = alumni.WebSite,
|
|
||||||
Experiences = alumni.Experiences.Select(e => e.ToDto()),
|
|
||||||
Formations = alumni.Formations.Select(f => f.ToDto())
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseRestrictedAlumniDto ToDtoRestricted(this User alumni)
|
|
||||||
{
|
|
||||||
return new ResponseRestrictedAlumniDto
|
|
||||||
{
|
|
||||||
Id = alumni.Id,
|
|
||||||
FirstName = alumni.FirstName,
|
|
||||||
LastName = alumni.LastName,
|
|
||||||
LinkedinUrl = alumni.Linkedin
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static User ToEntity(this RequestAlumniDto alumni)
|
|
||||||
{
|
|
||||||
return new User
|
|
||||||
{
|
|
||||||
Email = alumni.Email,
|
|
||||||
Password = alumni.Password,
|
|
||||||
EntryYear = alumni.EntryYear,
|
|
||||||
FirstName = alumni.FirstName,
|
|
||||||
LastName = alumni.LastName,
|
|
||||||
Linkedin = alumni.LinkedinUrl,
|
|
||||||
Github = alumni.GithubUrl,
|
|
||||||
WebSite = alumni.PortfolioUrl,
|
|
||||||
Role = "USER"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ERole ToERole(this string role)
|
|
||||||
{
|
|
||||||
return role switch
|
|
||||||
{
|
|
||||||
"ADMIN" => ERole.ADMIN,
|
|
||||||
"MODERATOR" => ERole.MODERATOR,
|
|
||||||
"USER" => ERole.USER
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
using Infrastructure.Entities;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
|
|
||||||
namespace Server.Mappers;
|
|
||||||
|
|
||||||
public static class EventsMappers
|
|
||||||
{
|
|
||||||
public static ResponseEventDto ToDto(this EventEntity evt)
|
|
||||||
{
|
|
||||||
return new ResponseEventDto
|
|
||||||
{
|
|
||||||
Id = evt.Id,
|
|
||||||
Title = evt.Title,
|
|
||||||
Description = evt.Description,
|
|
||||||
Date = evt.Date,
|
|
||||||
nbMaxRegistrations = evt.nbPlaces,
|
|
||||||
nbRegistrations = evt.Participants.Count
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EventEntity ToEntity(this RequestEventDto evt)
|
|
||||||
{
|
|
||||||
return new EventEntity
|
|
||||||
{
|
|
||||||
Title = evt.Title,
|
|
||||||
Description = evt.Description,
|
|
||||||
Date = evt.Date,
|
|
||||||
nbPlaces = evt.nbMaxRegistrations
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,36 @@
|
|||||||
|
using Infrastructure.Entities;
|
||||||
|
using Server.Dto.Request;
|
||||||
|
using Server.Dto.Response;
|
||||||
|
using AutoMapper;
|
||||||
|
|
||||||
|
namespace Server.Mappers;
|
||||||
|
|
||||||
|
public class UsersMappers : Profile
|
||||||
|
{
|
||||||
|
public UsersMappers()
|
||||||
|
{
|
||||||
|
_ = CreateMap<User, ResponseUserDto>()
|
||||||
|
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
|
||||||
|
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
|
||||||
|
.ForMember(dest => dest.Age, opt => opt.MapFrom(src => src.Age))
|
||||||
|
.ForMember(dest => dest.Height, opt => opt.MapFrom(src => src.Height))
|
||||||
|
.ForMember(dest => dest.Weight, opt => opt.MapFrom(src => src.Weight))
|
||||||
|
.ForMember(dest => dest.Sexe, opt => opt.MapFrom(src => src.Sexe))
|
||||||
|
.ForMember(dest => dest.Logo, opt => opt.MapFrom(src => src.Logo))
|
||||||
|
.ForMember(dest => dest.NbSessionPerWeek, opt => opt.MapFrom(src => src.NbSessionPerWeek))
|
||||||
|
.ForMember(dest => dest.EGoal, opt => opt.MapFrom(src => src.EGoal))
|
||||||
|
.ForMember(dest => dest.ESleepLevel, opt => opt.MapFrom(src => src.ESleepLevel));
|
||||||
|
|
||||||
|
_ = CreateMap<RequestUserDto, User>()
|
||||||
|
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name));
|
||||||
|
//.ForMember(dest => dest.Age, opt => opt.MapFrom(src => src.Age))
|
||||||
|
//.ForMember(dest => dest.Height, opt => opt.MapFrom(src => src.Height))
|
||||||
|
//.ForMember(dest => dest.Weight, opt => opt.MapFrom(src => src.Weight))
|
||||||
|
//.ForMember(dest => dest.Sexe, opt => opt.MapFrom(src => src.Sexe))
|
||||||
|
//.ForMember(dest => dest.Logo, opt => opt.MapFrom(src => src.Logo))
|
||||||
|
//.ForMember(dest => dest.NbSessionPerWeek, opt => opt.MapFrom(src => src.NbSessionPerWeek))
|
||||||
|
//.ForMember(dest => dest.EGoal, opt => opt.MapFrom(src => src.EGoal))
|
||||||
|
//.ForMember(dest => dest.ESleepLevel, opt => opt.MapFrom(src => src.ESleepLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ActiveDebugProfile>https</ActiveDebugProfile>
|
|
||||||
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
|
||||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
@ -1,83 +0,0 @@
|
|||||||
using Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Server.IServices;
|
|
||||||
using Server.Mappers;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace Server.Services;
|
|
||||||
|
|
||||||
public class AlumniService(AlumniDbContext context) : IAlumnisService
|
|
||||||
{
|
|
||||||
public Task<(long Count, IEnumerable<ResponseRestrictedAlumniDto> Alumnis)> GetAlumnisRestricted(string? lastname, int page, int size,
|
|
||||||
AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None, bool ascending = true)
|
|
||||||
{
|
|
||||||
var query = context.Alumni.Skip((page-1) * size).Take(size);
|
|
||||||
if (lastname != null)
|
|
||||||
{
|
|
||||||
query = context.Alumni.Where(e => e.LastName.Contains(lastname)).Skip((page-1) * size).Take(size);
|
|
||||||
}
|
|
||||||
switch (orderCriteria)
|
|
||||||
{
|
|
||||||
case AlumniOrderCriteria.Name:
|
|
||||||
query = ascending ? query.OrderBy(e => e.LastName) : query.OrderByDescending(e => e.LastName);
|
|
||||||
break;
|
|
||||||
case AlumniOrderCriteria.None:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var count = query.LongCount();
|
|
||||||
return Task.FromResult((count, query.AsEnumerable().Select(e => e.ToDtoRestricted())));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<ResponseRestrictedAlumniDto?> GetAlumniRestrictedById(string id)
|
|
||||||
{
|
|
||||||
var result = context.Alumni.FirstOrDefault(e => e.Id == id);
|
|
||||||
return Task.FromResult(result?.ToDtoRestricted());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<ResponseAlumniDto?> GetAlumniById(string id)
|
|
||||||
{
|
|
||||||
var result = context.Alumni
|
|
||||||
.Include(a => a.Experiences)
|
|
||||||
.Include(a => a.Formations)
|
|
||||||
.FirstOrDefault(e => e.Id == id);
|
|
||||||
return Task.FromResult(result?.ToDto());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<(long Count, IEnumerable<ResponseAlumniDto> Alumnis)> GetAlumnis(string? lastname, int page, int size,
|
|
||||||
AlumniOrderCriteria orderCriteria = AlumniOrderCriteria.None,
|
|
||||||
bool ascending = true)
|
|
||||||
{
|
|
||||||
var query = context.Alumni
|
|
||||||
.Include(a => a.Experiences)
|
|
||||||
.Include(a => a.Formations)
|
|
||||||
.Skip((page-1) * size)
|
|
||||||
.Take(size);
|
|
||||||
if (lastname != null)
|
|
||||||
{
|
|
||||||
query = context.Alumni.Where(e => e.LastName.Contains(lastname))
|
|
||||||
.Include(a => a.Experiences)
|
|
||||||
.Include(a => a.Formations)
|
|
||||||
.Skip((page-1) * size)
|
|
||||||
.Take(size);
|
|
||||||
}
|
|
||||||
switch (orderCriteria)
|
|
||||||
{
|
|
||||||
case AlumniOrderCriteria.Name:
|
|
||||||
query = ascending ? query.OrderBy(e => e.LastName) : query.OrderByDescending(e => e.LastName);
|
|
||||||
break;
|
|
||||||
case AlumniOrderCriteria.None:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var count = query.LongCount();
|
|
||||||
return Task.FromResult((count, query.AsEnumerable().Select(e => e.ToDto())));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<ResponseAlumniDto?> CreateAlumni(RequestAlumniDto alumni)
|
|
||||||
{
|
|
||||||
var result = context.Alumni.AddAsync(alumni.ToEntity());
|
|
||||||
context.SaveChangesAsync();
|
|
||||||
return Task.FromResult(result.Result?.Entity.ToDto());
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,38 @@
|
|||||||
|
using Infrastructure;
|
||||||
|
using Infrastructure.Repositories;
|
||||||
|
using Server.Dto.Response;
|
||||||
|
using Server.IServices;
|
||||||
|
using AutoMapper;
|
||||||
|
using Shared;
|
||||||
|
|
||||||
|
namespace Server.Services;
|
||||||
|
|
||||||
|
public class UsersService : IUsersService
|
||||||
|
{
|
||||||
|
private readonly OptifitDbContext _context;
|
||||||
|
private readonly UserRepository _userRepository;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public UsersService(OptifitDbContext context, UserRepository userRepository, IMapper mapper)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_userRepository = userRepository;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ResponseUserDto?> GetUserById(string id)
|
||||||
|
{
|
||||||
|
var userEntity = await _userRepository.GetByIdAsync(id);
|
||||||
|
if (userEntity == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var userDto = _mapper.Map<ResponseUserDto>(userEntity);
|
||||||
|
return userDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<PaginatedResult<ResponseUserDto>> GetUsers(int page, int size, bool ascending = true)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
namespace Shared.Criteria;
|
|
||||||
|
|
||||||
public enum AlumniOrderCriteria
|
|
||||||
{
|
|
||||||
Name,
|
|
||||||
None
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace Shared.Criteria;
|
|
||||||
|
|
||||||
public enum EventOrderCriteria
|
|
||||||
{
|
|
||||||
Title,
|
|
||||||
Date,
|
|
||||||
NbPlaces
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace Shared.Criteria;
|
|
||||||
|
|
||||||
public enum ExperienceOrderCriteria
|
|
||||||
{
|
|
||||||
Title,
|
|
||||||
StartDate,
|
|
||||||
EndDate
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace Shared.Criteria;
|
|
||||||
|
|
||||||
public enum FormationOrderCriteria
|
|
||||||
{
|
|
||||||
Name,
|
|
||||||
StartDate,
|
|
||||||
EndDate,
|
|
||||||
SchoolName,
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace Shared.Enums;
|
|
||||||
|
|
||||||
public enum EContract
|
|
||||||
{
|
|
||||||
CDI,
|
|
||||||
CDD,
|
|
||||||
INTERNSHIP,
|
|
||||||
APPRENTICESHIP
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace Shared.Enums;
|
|
||||||
|
|
||||||
public enum ELevel
|
|
||||||
{
|
|
||||||
JUNIOR,
|
|
||||||
SENIOR,
|
|
||||||
INDEFERENT
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace Shared.Enums;
|
|
||||||
|
|
||||||
public enum ERole
|
|
||||||
{
|
|
||||||
ADMIN,
|
|
||||||
MODERATOR,
|
|
||||||
USER
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace Shared.Enums;
|
|
||||||
|
|
||||||
public enum EStudies
|
|
||||||
{
|
|
||||||
BAC_2,
|
|
||||||
BAC_3,
|
|
||||||
BAC_5,
|
|
||||||
INDIFERENT
|
|
||||||
}
|
|
@ -0,0 +1,26 @@
|
|||||||
|
namespace Shared;
|
||||||
|
|
||||||
|
public class PaginatedResult<T>
|
||||||
|
{
|
||||||
|
public PaginatedResult(List<T>? data = default, int count = 0, int page = 0, int pageSize = 10)
|
||||||
|
{
|
||||||
|
Data = data;
|
||||||
|
CurrentPage = page;
|
||||||
|
PageSize = pageSize;
|
||||||
|
TotalCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T>? Data { get; set; }
|
||||||
|
|
||||||
|
public int CurrentPage { get; set; }
|
||||||
|
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
|
||||||
|
public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);
|
||||||
|
|
||||||
|
public bool HasPreviousPage => CurrentPage > 0;
|
||||||
|
|
||||||
|
public bool HasNextPage => CurrentPage < (TotalPages - 1);
|
||||||
|
}
|
@ -1,130 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Moq;
|
|
||||||
using Server.Controller.v1;
|
|
||||||
using Server.Dto.Response;
|
|
||||||
using Server.IServices;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
namespace TestAPI.ControllerTests
|
|
||||||
{
|
|
||||||
public class AlumniControllerTest
|
|
||||||
{
|
|
||||||
private readonly Mock<ILogger<AlumnisController>> _loggerMock = new Mock<ILogger<AlumnisController>>();
|
|
||||||
private readonly Mock<IAlumnisService> _alumnisServiceMock = new Mock<IAlumnisService>();
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetAlumni_NoAlumni_ReturnsNoContent()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
_alumnisServiceMock.Setup(service => service.GetAlumnis(null, 1, 5, AlumniOrderCriteria.None, true))
|
|
||||||
.ReturnsAsync((0, Enumerable.Empty<ResponseAlumniDto>()));
|
|
||||||
|
|
||||||
var controller = new AlumnisController(_loggerMock.Object, _alumnisServiceMock.Object);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = controller.GetAlumni(null);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var actionResult = Assert.IsType<NoContentResult>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetAlumni_AlumniExists_ReturnsOk()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var alumniList = new List<ResponseAlumniDto>
|
|
||||||
{
|
|
||||||
new ResponseAlumniDto { Id = "1", FirstName = "John", LastName = "Doe" }
|
|
||||||
};
|
|
||||||
_alumnisServiceMock.Setup(service => service.GetAlumnis(null, 1, 5, AlumniOrderCriteria.None, true))
|
|
||||||
.ReturnsAsync((alumniList.Count, alumniList));
|
|
||||||
|
|
||||||
var controller = new AlumnisController(_loggerMock.Object, _alumnisServiceMock.Object);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = controller.GetAlumni(null);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var actionResult = Assert.IsType<OkObjectResult>(result);
|
|
||||||
var returnValue = Assert.IsAssignableFrom<IEnumerable<ResponseAlumniDto>>(actionResult.Value);
|
|
||||||
Assert.Single(returnValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetAlumniById_AlumniExists_ReturnsOk()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var alumniId = "1";
|
|
||||||
var alumniDto = new ResponseAlumniDto { Id = alumniId };
|
|
||||||
_alumnisServiceMock.Setup(service => service.GetAlumniById(alumniId)).ReturnsAsync(alumniDto);
|
|
||||||
|
|
||||||
var controller = new AlumnisController(_loggerMock.Object, _alumnisServiceMock.Object);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = controller.GetAlumniById(alumniId);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var actionResult = Assert.IsType<OkObjectResult>(result);
|
|
||||||
var returnValue = Assert.IsType<Task<ResponseAlumniDto>>(actionResult.Value);
|
|
||||||
Assert.Equal(alumniId, returnValue.Result.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetAlumniById_AlumniDoesNotExist_ReturnsNotFound()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var alumniId = "1";
|
|
||||||
_alumnisServiceMock.Setup(service => service.GetAlumniById(alumniId)).ReturnsAsync((ResponseAlumniDto)null);
|
|
||||||
|
|
||||||
var controller = new AlumnisController(_loggerMock.Object, _alumnisServiceMock.Object);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = controller.GetAlumniById(alumniId);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var actionResult = Assert.IsType<NotFoundResult>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetAlumni_ByLastName_NoAlumni_ReturnsNoContent()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var lastName = "Doe";
|
|
||||||
_alumnisServiceMock.Setup(service => service.GetAlumnis(lastName, 1, 5, AlumniOrderCriteria.None, true))
|
|
||||||
.ReturnsAsync((0, new List<ResponseAlumniDto>()));
|
|
||||||
|
|
||||||
var controller = new AlumnisController(_loggerMock.Object, _alumnisServiceMock.Object);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = controller.GetAlumni(lastName);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var actionResult = Assert.IsType<NoContentResult>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetAlumni_ByLastName_AlumniExist_ReturnsOk()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var lastName = "Doe";
|
|
||||||
var alumniList = new List<ResponseAlumniDto>
|
|
||||||
{
|
|
||||||
new ResponseAlumniDto { Id = "1", LastName = "Doe" }
|
|
||||||
};
|
|
||||||
_alumnisServiceMock.Setup(service => service.GetAlumnis(lastName, 1, 5, AlumniOrderCriteria.None, true))
|
|
||||||
.ReturnsAsync((alumniList.Count, alumniList));
|
|
||||||
|
|
||||||
var controller = new AlumnisController(_loggerMock.Object, _alumnisServiceMock.Object);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = controller.GetAlumni(lastName);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var actionResult = Assert.IsType<OkObjectResult>(result);
|
|
||||||
var returnValue = Assert.IsAssignableFrom<IEnumerable<ResponseAlumniDto>>(actionResult.Value);
|
|
||||||
Assert.Single(returnValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
|||||||
using Xunit;
|
|
||||||
using Moq;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Services;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
public class AlumniServiceTests
|
|
||||||
{
|
|
||||||
private readonly Mock<AlumniDbContext> _mockContext;
|
|
||||||
private readonly AlumniService _alumniService;
|
|
||||||
|
|
||||||
public AlumniServiceTests()
|
|
||||||
{
|
|
||||||
var alumni = new List<User>
|
|
||||||
{
|
|
||||||
new User { Id = "1", LastName = "Alumni1" },
|
|
||||||
new User { Id = "2", LastName = "Alumni2" }
|
|
||||||
}.AsQueryable();
|
|
||||||
|
|
||||||
var mockSet = new Mock<DbSet<User>>();
|
|
||||||
mockSet.As<IQueryable<User>>().Setup(m => m.Provider).Returns(alumni.Provider);
|
|
||||||
mockSet.As<IQueryable<User>>().Setup(m => m.Expression).Returns(alumni.Expression);
|
|
||||||
mockSet.As<IQueryable<User>>().Setup(m => m.ElementType).Returns(alumni.ElementType);
|
|
||||||
mockSet.As<IQueryable<User>>().Setup(m => m.GetEnumerator()).Returns(alumni.GetEnumerator());
|
|
||||||
|
|
||||||
_mockContext = new Mock<AlumniDbContext>();
|
|
||||||
_mockContext.Setup(c => c.Alumni).Returns(mockSet.Object);
|
|
||||||
|
|
||||||
_alumniService = new AlumniService(_mockContext.Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetAlumniById_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _alumniService.GetAlumniById("3");
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetAlumnis_ReturnsEmpty_WhenLastNameDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _alumniService.GetAlumnis("Alumni3", 1, 1, AlumniOrderCriteria.Name, true);
|
|
||||||
Assert.Empty(result.Alumnis);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetAlumnisRestricted_NoMatchingLastName_ReturnsEmpty()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
string lastName = "NonExistingLastName";
|
|
||||||
var page = 1;
|
|
||||||
var size = 5;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _alumniService.GetAlumnisRestricted(lastName, page, size);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Empty(result.Alumnis);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetAlumnisRestricted_MatchingLastName_ReturnsAlumni()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
string lastName = "Alumni1";
|
|
||||||
var page = 1;
|
|
||||||
var size = 5;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _alumniService.GetAlumnisRestricted(lastName, page, size);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(result.Alumnis);
|
|
||||||
Assert.Equal(1, result.Alumnis.Count());
|
|
||||||
Assert.Equal("Alumni1", result.Alumnis.First().LastName);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetAlumnisRestricted_PaginationWorksCorrectly()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
string lastName = null;
|
|
||||||
var page = 2;
|
|
||||||
var size = 1;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _alumniService.GetAlumnisRestricted(lastName, page, size);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(result.Alumnis);
|
|
||||||
Assert.Single(result.Alumnis);
|
|
||||||
Assert.Equal("Alumni2", result.Alumnis.First().LastName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
using Xunit;
|
|
||||||
using Moq;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Services;
|
|
||||||
using Shared.Criteria;
|
|
||||||
|
|
||||||
public class EventServicesTests
|
|
||||||
{
|
|
||||||
private readonly Mock<AlumniDbContext> _mockContext;
|
|
||||||
private readonly EventServices _eventServices;
|
|
||||||
|
|
||||||
public EventServicesTests()
|
|
||||||
{
|
|
||||||
var events = new List<EventEntity>
|
|
||||||
{
|
|
||||||
new EventEntity { Id = "1", Title = "Event1", Description = "Description1", Date = DateTime.Now, nbPlaces = 100 },
|
|
||||||
new EventEntity { Id = "2", Title = "Event2", Description = "Description2", Date = DateTime.Now.AddDays(1), nbPlaces = 200 }
|
|
||||||
}.AsQueryable();
|
|
||||||
|
|
||||||
var mockSet = new Mock<DbSet<EventEntity>>();
|
|
||||||
mockSet.As<IQueryable<EventEntity>>().Setup(m => m.Provider).Returns(events.Provider);
|
|
||||||
mockSet.As<IQueryable<EventEntity>>().Setup(m => m.Expression).Returns(events.Expression);
|
|
||||||
mockSet.As<IQueryable<EventEntity>>().Setup(m => m.ElementType).Returns(events.ElementType);
|
|
||||||
mockSet.As<IQueryable<EventEntity>>().Setup(m => m.GetEnumerator()).Returns(events.GetEnumerator());
|
|
||||||
|
|
||||||
_mockContext = new Mock<AlumniDbContext>();
|
|
||||||
_mockContext.Setup(c => c.Events).Returns(mockSet.Object);
|
|
||||||
|
|
||||||
_eventServices = new EventServices(_mockContext.Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetEventById_ReturnsEvent_WhenIdExists()
|
|
||||||
{
|
|
||||||
var result = await _eventServices.GetEventById("1");
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.Equal("1", result.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetEventById_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _eventServices.GetEventById("3");
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetEvents_ReturnsEvents_WhenTitleExists()
|
|
||||||
{
|
|
||||||
var result = await _eventServices.GetEvents("Event1", 1, 1, EventOrderCriteria.Date, true);
|
|
||||||
Assert.Single(result.Events);
|
|
||||||
Assert.Equal("Event1", result.Events.First().Title);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetEvents_ReturnsEmpty_WhenTitleDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _eventServices.GetEvents("Event3", 1, 1, EventOrderCriteria.Date, true);
|
|
||||||
Assert.Empty(result.Events);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateEvent_ReturnsUpdatedEvent_WhenIdExists()
|
|
||||||
{
|
|
||||||
var eventDto = new RequestEventDto { Title = "UpdatedEvent", Description = "UpdatedDescription", Date = DateTime.Now, nbMaxRegistrations = 150 };
|
|
||||||
var result = await _eventServices.UpdateEvent("1", eventDto);
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.Equal("UpdatedEvent", result.Title);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateEvent_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var eventDto = new RequestEventDto { Title = "UpdatedEvent", Description = "UpdatedDescription", Date = DateTime.Now, nbMaxRegistrations = 150 };
|
|
||||||
var result = await _eventServices.UpdateEvent("3", eventDto);
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DeleteEvent_ReturnsTrue_WhenIdExists()
|
|
||||||
{
|
|
||||||
var result = await _eventServices.DeleteEvent("1");
|
|
||||||
Assert.True(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DeleteEvent_ReturnsFalse_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _eventServices.DeleteEvent("3");
|
|
||||||
Assert.False(result);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
using Moq;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Services;
|
|
||||||
|
|
||||||
public class ExperienceServicesTests
|
|
||||||
{
|
|
||||||
private readonly Mock<AlumniDbContext> _mockContext;
|
|
||||||
private readonly ExperienceServices _experienceServices;
|
|
||||||
|
|
||||||
public ExperienceServicesTests()
|
|
||||||
{
|
|
||||||
var experiences = new List<ExperienceEntity>
|
|
||||||
{
|
|
||||||
new ExperienceEntity { Id = "1", Title = "Experience1", CompanyName = "Company1", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(30), IsCurrent = true },
|
|
||||||
new ExperienceEntity { Id = "2", Title = "Experience2", CompanyName = "Company2", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(30), IsCurrent = false }
|
|
||||||
}.AsQueryable();
|
|
||||||
|
|
||||||
var mockSet = new Mock<DbSet<ExperienceEntity>>();
|
|
||||||
mockSet.As<IQueryable<ExperienceEntity>>().Setup(m => m.Provider).Returns(experiences.Provider);
|
|
||||||
mockSet.As<IQueryable<ExperienceEntity>>().Setup(m => m.Expression).Returns(experiences.Expression);
|
|
||||||
mockSet.As<IQueryable<ExperienceEntity>>().Setup(m => m.ElementType).Returns(experiences.ElementType);
|
|
||||||
mockSet.As<IQueryable<ExperienceEntity>>().Setup(m => m.GetEnumerator()).Returns(experiences.GetEnumerator());
|
|
||||||
|
|
||||||
_mockContext = new Mock<AlumniDbContext>();
|
|
||||||
_mockContext.Setup(c => c.Experiences).Returns(mockSet.Object);
|
|
||||||
|
|
||||||
_experienceServices = new ExperienceServices(_mockContext.Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetExperienceById_ReturnsExperience_WhenIdExists()
|
|
||||||
{
|
|
||||||
var result = await _experienceServices.GetExperienceById("1");
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.Equal("1", result.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetExperienceById_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _experienceServices.GetExperienceById("3");
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetExperiences_ReturnsExperiences_WhenTitleExists()
|
|
||||||
{
|
|
||||||
var result = await _experienceServices.GetExperiences("Experience1", 1, 1);
|
|
||||||
Assert.Single(result.Experiences);
|
|
||||||
Assert.Equal("Experience1", result.Experiences.First().Title);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetExperiences_ReturnsEmpty_WhenTitleDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _experienceServices.GetExperiences("Experience3", 1, 1);
|
|
||||||
Assert.Empty(result.Experiences);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateExperience_ReturnsUpdatedExperience_WhenIdExists()
|
|
||||||
{
|
|
||||||
var experience = new RequestExperienceDto { Title = "UpdatedExperience", CompanyName = "UpdatedCompany", StartingDate = DateTime.Now, EndingDate = DateTime.Now.AddDays(30), CurrentJob = false };
|
|
||||||
var result = await _experienceServices.UpdateExperience("1", experience);
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.Equal("UpdatedExperience", result.Title);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateExperience_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var experience = new RequestExperienceDto { Title = "UpdatedExperience", CompanyName = "UpdatedCompany", StartingDate = DateTime.Now, EndingDate = DateTime.Now.AddDays(30), CurrentJob = false };
|
|
||||||
var result = await _experienceServices.UpdateExperience("3", experience);
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DeleteExperience_ReturnsTrue_WhenIdExists()
|
|
||||||
{
|
|
||||||
var result = await _experienceServices.DeleteExperience("1");
|
|
||||||
Assert.True(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DeleteExperience_ReturnsFalse_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _experienceServices.DeleteExperience("3");
|
|
||||||
Assert.False(result);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,143 +0,0 @@
|
|||||||
using Moq;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Server.Dto.Request;
|
|
||||||
using Server.Services;
|
|
||||||
|
|
||||||
public class FormationServicesTests
|
|
||||||
{
|
|
||||||
private readonly Mock<AlumniDbContext> _mockContext;
|
|
||||||
private readonly FormationServices _formationServices;
|
|
||||||
|
|
||||||
public FormationServicesTests()
|
|
||||||
{
|
|
||||||
var formations = new List<FormationEntity>
|
|
||||||
{
|
|
||||||
new FormationEntity { Id = "1", Name = "Formation1", SchoolName = "School1", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(30), IsCurrent = true },
|
|
||||||
new FormationEntity { Id = "2", Name = "Formation2", SchoolName = "School2", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(30), IsCurrent = true }
|
|
||||||
}.AsQueryable();
|
|
||||||
|
|
||||||
var mockSet = new Mock<DbSet<FormationEntity>>();
|
|
||||||
mockSet.As<IQueryable<FormationEntity>>().Setup(m => m.Provider).Returns(formations.Provider);
|
|
||||||
mockSet.As<IQueryable<FormationEntity>>().Setup(m => m.Expression).Returns(formations.Expression);
|
|
||||||
mockSet.As<IQueryable<FormationEntity>>().Setup(m => m.ElementType).Returns(formations.ElementType);
|
|
||||||
mockSet.As<IQueryable<FormationEntity>>().Setup(m => m.GetEnumerator()).Returns(formations.GetEnumerator());
|
|
||||||
|
|
||||||
_mockContext = new Mock<AlumniDbContext>();
|
|
||||||
_mockContext.Setup(c => c.Formations).Returns(mockSet.Object);
|
|
||||||
|
|
||||||
_formationServices = new FormationServices(_mockContext.Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormationById_ReturnsFormation_WhenIdExists()
|
|
||||||
{
|
|
||||||
var result = await _formationServices.GetFormationById("1");
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.Equal("1", result.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormationById_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _formationServices.GetFormationById("3");
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormations_ReturnsFormations_WhenNameExists()
|
|
||||||
{
|
|
||||||
var result = await _formationServices.GetFormations("Formation1", 1, 1);
|
|
||||||
Assert.Single(result.Formations);
|
|
||||||
Assert.Equal("Formation1", result.Formations.First().Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormations_ReturnsEmpty_WhenNameDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _formationServices.GetFormations("Formation3", 1, 1);
|
|
||||||
Assert.Empty(result.Formations);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateFormation_ReturnsUpdatedFormation_WhenIdExists()
|
|
||||||
{
|
|
||||||
var formation = new RequestFormationDto { Name = "UpdatedFormation", SchoolName = "UpdatedSchool", StartingDate = DateTime.Now, EndingDate = DateTime.Now.AddDays(30), CurrentFormation = false };
|
|
||||||
var result = await _formationServices.UpdateFormation("1", formation);
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.Equal("UpdatedFormation", result.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task UpdateFormation_ReturnsNull_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var formation = new RequestFormationDto { Name = "UpdatedFormation", SchoolName = "UpdatedSchool", StartingDate = DateTime.Now, EndingDate = DateTime.Now.AddDays(30), CurrentFormation = false };
|
|
||||||
var result = await _formationServices.UpdateFormation("3", formation);
|
|
||||||
Assert.Null(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DeleteFormation_ReturnsTrue_WhenIdExists()
|
|
||||||
{
|
|
||||||
var result = await _formationServices.DeleteFormation("1");
|
|
||||||
Assert.True(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task DeleteFormation_ReturnsFalse_WhenIdDoesNotExist()
|
|
||||||
{
|
|
||||||
var result = await _formationServices.DeleteFormation("3");
|
|
||||||
Assert.False(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormations_NoName_ReturnsFormations()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
string name = null;
|
|
||||||
var page = 1;
|
|
||||||
var size = 5;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _formationServices.GetFormations(name, page, size);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(result.Formations);
|
|
||||||
Assert.Equal(2, result.Formations.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormations_MatchingName_ReturnsFilteredFormations()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
string name = "Formation1";
|
|
||||||
var page = 1;
|
|
||||||
var size = 5;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _formationServices.GetFormations(name, page, size);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Single(result.Formations);
|
|
||||||
Assert.Equal("Formation1", result.Formations.First().Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetFormations_PaginationWorksCorrectly()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
string name = null;
|
|
||||||
var page = 2;
|
|
||||||
var size = 1;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _formationServices.GetFormations(name, page, size);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.NotEmpty(result.Formations);
|
|
||||||
Assert.Single(result.Formations);
|
|
||||||
Assert.Equal("Formation2", result.Formations.First().Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,194 +0,0 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace UnitTestEF.Entities;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class AlumniTest
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public async Task AddAlumniTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
|
|
||||||
var alumnis = new List<User>(
|
|
||||||
[
|
|
||||||
new User
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
FirstName = "Test",
|
|
||||||
LastName = "Test",
|
|
||||||
Email = "test@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "ADMIN"
|
|
||||||
},
|
|
||||||
new User
|
|
||||||
{
|
|
||||||
Id = "2",
|
|
||||||
FirstName = "Test2",
|
|
||||||
LastName = "Test2",
|
|
||||||
Email = "test2@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "USER",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
await context.Alumni.AddRangeAsync(alumnis);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
Assert.AreEqual(2, await context.Alumni.CountAsync());
|
|
||||||
|
|
||||||
var inBaseAlumni = await context.Alumni.FirstOrDefaultAsync(a => a.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseAlumni);
|
|
||||||
Assert.AreEqual("1", inBaseAlumni.Id);
|
|
||||||
Assert.AreEqual("Test", inBaseAlumni.FirstName);
|
|
||||||
Assert.AreEqual("Test", inBaseAlumni.LastName);
|
|
||||||
Assert.AreEqual("test@gmail.com", inBaseAlumni.Email);
|
|
||||||
Assert.AreEqual("2021", inBaseAlumni.EntryYear);
|
|
||||||
Assert.AreEqual("1234567890", inBaseAlumni.Password);
|
|
||||||
Assert.AreEqual("ADMIN", inBaseAlumni.Role);
|
|
||||||
|
|
||||||
var inBaseAlumni2 = await context.Alumni.FirstOrDefaultAsync(a => a.Id == "2");
|
|
||||||
Assert.IsNotNull(inBaseAlumni2);
|
|
||||||
Assert.AreEqual("2", inBaseAlumni2.Id);
|
|
||||||
Assert.AreEqual("Test2", inBaseAlumni2.FirstName);
|
|
||||||
Assert.AreEqual("Test2", inBaseAlumni2.LastName);
|
|
||||||
Assert.AreEqual("test2@gmail.com", inBaseAlumni2.Email);
|
|
||||||
Assert.AreEqual("2021", inBaseAlumni2.EntryYear);
|
|
||||||
Assert.AreEqual("1234567890", inBaseAlumni2.Password);
|
|
||||||
Assert.AreEqual("USER", inBaseAlumni2.Role);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task DeleteAlumniTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
|
|
||||||
var alumni = new User
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
FirstName = "Test",
|
|
||||||
LastName = "Test",
|
|
||||||
Email = "test@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "ADMIN"
|
|
||||||
};
|
|
||||||
|
|
||||||
await context.Alumni.AddAsync(alumni);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
Assert.AreEqual(1, await context.Alumni.CountAsync());
|
|
||||||
|
|
||||||
var inBaseAlumni = await context.Alumni.FirstOrDefaultAsync(a => a.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseAlumni);
|
|
||||||
|
|
||||||
context.Alumni.Remove(alumni);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
Assert.AreEqual(0, await context.Alumni.CountAsync());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task UpdateAlumniTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
|
|
||||||
var alumni = new User
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
FirstName = "Test",
|
|
||||||
LastName = "Test",
|
|
||||||
Email = "test@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "ADMIN"
|
|
||||||
};
|
|
||||||
|
|
||||||
await context.Alumni.AddAsync(alumni);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
Assert.AreEqual(1, await context.Alumni.CountAsync());
|
|
||||||
|
|
||||||
var inBaseAlumni = await context.Alumni.FirstOrDefaultAsync(a => a.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseAlumni);
|
|
||||||
|
|
||||||
inBaseAlumni.FirstName = "Test2";
|
|
||||||
inBaseAlumni.LastName = "Test2";
|
|
||||||
inBaseAlumni.Email = "test2@gmail.com";
|
|
||||||
inBaseAlumni.EntryYear = "2022";
|
|
||||||
inBaseAlumni.Password = "0987654321";
|
|
||||||
inBaseAlumni.Role = "USER";
|
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var alumniAfterUpdate = await context.Alumni.FirstOrDefaultAsync(a => a.Id == "1");
|
|
||||||
Assert.IsNotNull(alumniAfterUpdate);
|
|
||||||
Assert.AreEqual("1", alumniAfterUpdate.Id);
|
|
||||||
Assert.AreEqual("Test2", alumniAfterUpdate.FirstName);
|
|
||||||
Assert.AreEqual("Test2", alumniAfterUpdate.LastName);
|
|
||||||
Assert.AreEqual("test2@gmail.com", alumniAfterUpdate.Email);
|
|
||||||
Assert.AreEqual("2022", alumniAfterUpdate.EntryYear);
|
|
||||||
Assert.AreEqual("0987654321", alumniAfterUpdate.Password);
|
|
||||||
Assert.AreEqual("USER", alumniAfterUpdate.Role);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ToString_ReturnsCorrectFormat()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var alumni = new User
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
FirstName = "Test",
|
|
||||||
LastName = "Test",
|
|
||||||
Email = "test@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "ADMIN",
|
|
||||||
Experiences = new List<ExperienceEntity>(),
|
|
||||||
Formations = new List<FormationEntity>(),
|
|
||||||
Events = new List<EventEntity>()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = alumni.ToString();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var expected = "\t------------Alumni Id : 1 ------------- :\n\tFirstname : Test Lastname : Test Email : test@gmail.com Role : ADMIN\n\tExperiences : 0 \tFormations : 0 \t Events : 0";
|
|
||||||
Assert.AreEqual(expected, result);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,211 +0,0 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace UnitTestEF.Entities;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class EventTest
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public async Task AddEventTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newEvent = new EventEntity
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
Title = "A Test Event",
|
|
||||||
Description = "A Test Description",
|
|
||||||
Date = new DateTime(2020, 9, 1),
|
|
||||||
nbPlaces = 50
|
|
||||||
};
|
|
||||||
await context.Events.AddAsync(newEvent);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
Assert.AreEqual(1, await context.Events.CountAsync());
|
|
||||||
|
|
||||||
var inBaseEvent = await context.Events.FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseEvent);
|
|
||||||
Assert.AreEqual("1", inBaseEvent.Id);
|
|
||||||
Assert.AreEqual("A Test Event", inBaseEvent.Title);
|
|
||||||
Assert.AreEqual("A Test Description", inBaseEvent.Description);
|
|
||||||
Assert.AreEqual(new DateTime(2020, 9, 1), inBaseEvent.Date);
|
|
||||||
Assert.AreEqual(50, inBaseEvent.nbPlaces);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task RemoveEventTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newEvent = new EventEntity
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
Title = "A Test Event",
|
|
||||||
Description = "A Test Description",
|
|
||||||
Date = new DateTime(2020, 9, 1),
|
|
||||||
nbPlaces = 50
|
|
||||||
};
|
|
||||||
await context.Events.AddAsync(newEvent);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseEvent = await context.Events.FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseEvent);
|
|
||||||
|
|
||||||
context.Events.Remove(newEvent);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var eventAfterDelete = await context.Events.FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNull(eventAfterDelete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task UpdateEventTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newEvent = new EventEntity
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
Title = "A Test Event",
|
|
||||||
Description = "A Test Description",
|
|
||||||
Date = new DateTime(2020, 9, 1),
|
|
||||||
nbPlaces = 50
|
|
||||||
};
|
|
||||||
await context.Events.AddAsync(newEvent);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseEvent = await context.Events.FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseEvent);
|
|
||||||
|
|
||||||
inBaseEvent.Title = "A New Title";
|
|
||||||
inBaseEvent.Description = "A New Description";
|
|
||||||
inBaseEvent.Date = new DateTime(2020, 9, 2);
|
|
||||||
inBaseEvent.nbPlaces = 100;
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var eventAfterUpdate = await context.Events.FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNotNull(eventAfterUpdate);
|
|
||||||
Assert.AreEqual("1", eventAfterUpdate.Id);
|
|
||||||
Assert.AreEqual("A New Title", eventAfterUpdate.Title);
|
|
||||||
Assert.AreEqual("A New Description", eventAfterUpdate.Description);
|
|
||||||
Assert.AreEqual(new DateTime(2020, 9, 2), eventAfterUpdate.Date);
|
|
||||||
Assert.AreEqual(100, eventAfterUpdate.nbPlaces);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task EventWithParticipantsTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newEvent = new EventEntity
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
Title = "A Test Event",
|
|
||||||
Description = "A Test Description",
|
|
||||||
Date = new DateTime(2020, 9, 1),
|
|
||||||
nbPlaces = 50
|
|
||||||
};
|
|
||||||
await context.Events.AddAsync(newEvent);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseEvent = await context.Events.FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNotNull(inBaseEvent);
|
|
||||||
|
|
||||||
var participants = new List<User>(
|
|
||||||
[
|
|
||||||
new User
|
|
||||||
{
|
|
||||||
Id = "1",
|
|
||||||
FirstName = "Test",
|
|
||||||
LastName = "Test",
|
|
||||||
Email = "test@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "ADMIN"
|
|
||||||
},
|
|
||||||
new User
|
|
||||||
{
|
|
||||||
Id = "2",
|
|
||||||
FirstName = "Test2",
|
|
||||||
LastName = "Test2",
|
|
||||||
Email = "test2@gmail.com",
|
|
||||||
EntryYear = "2021",
|
|
||||||
Password = "1234567890",
|
|
||||||
Role = "USER",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach (var p in participants)
|
|
||||||
{
|
|
||||||
inBaseEvent.Participants.Add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var eventWithParticipants = await context.Events.Include(e => e.Participants).FirstOrDefaultAsync(e => e.Id == "1");
|
|
||||||
Assert.IsNotNull(eventWithParticipants);
|
|
||||||
Assert.AreEqual(2, eventWithParticipants.Participants.Count);
|
|
||||||
|
|
||||||
foreach (var p in eventWithParticipants.Participants)
|
|
||||||
{
|
|
||||||
Assert.IsTrue(participants.Contains(p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ToString_ReturnsCorrectFormat()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var eventEntity = new EventEntity
|
|
||||||
{
|
|
||||||
Title = "Test Event",
|
|
||||||
Description = "This is a test event",
|
|
||||||
Date = new DateTime(2022, 1, 1),
|
|
||||||
nbPlaces = 100
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = eventEntity.ToString();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var expected = "\tTitle: Test Event, Date: 01/01/2022 00:00:00, nbPlaces: 100";
|
|
||||||
Assert.AreEqual(expected, result);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,150 +0,0 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace UnitTestEF.Entities;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class ExperienceTest
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public async Task AddFormationTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var exp = new ExperienceEntity()
|
|
||||||
{
|
|
||||||
Id = "100",
|
|
||||||
Title = "Software Engineer",
|
|
||||||
CompanyName = "CGI",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
await context.Experiences.AddAsync(exp);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseExp = await context.Experiences.FirstOrDefaultAsync(e => e.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseExp);
|
|
||||||
Assert.AreEqual("100", inBaseExp.Id);
|
|
||||||
Assert.AreEqual("Software Engineer", inBaseExp.Title);
|
|
||||||
Assert.AreEqual("CGI", inBaseExp.CompanyName);
|
|
||||||
Assert.AreEqual(new DateTime(2020, 9, 1), inBaseExp.StartDate);
|
|
||||||
Assert.AreEqual(new DateTime(2022, 6, 1), inBaseExp.EndDate);
|
|
||||||
Assert.IsTrue(inBaseExp.IsCurrent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task DeleteFormationTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var exp = new ExperienceEntity()
|
|
||||||
{
|
|
||||||
Id = "100",
|
|
||||||
Title = "Software Engineer",
|
|
||||||
CompanyName = "CGI",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
await context.Experiences.AddAsync(exp);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseExp = await context.Experiences.FirstOrDefaultAsync(e => e.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseExp);
|
|
||||||
|
|
||||||
context.Experiences.Remove(exp);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseExp2 = await context.Experiences.FirstOrDefaultAsync(e => e.Id == "100");
|
|
||||||
Assert.IsNull(inBaseExp2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task UpdateFormationTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
|
|
||||||
var exp = new ExperienceEntity()
|
|
||||||
{
|
|
||||||
Id = "100",
|
|
||||||
Title = "Software Engineer",
|
|
||||||
CompanyName = "CGI",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
|
|
||||||
await context.Experiences.AddAsync(exp);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseExp = await context.Experiences.FirstOrDefaultAsync(e => e.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseExp);
|
|
||||||
|
|
||||||
inBaseExp.Title = "Software Engineer II";
|
|
||||||
inBaseExp.CompanyName = "CGI II";
|
|
||||||
inBaseExp.StartDate = new DateTime(2021, 9, 1);
|
|
||||||
inBaseExp.EndDate = new DateTime(2023, 6, 1);
|
|
||||||
inBaseExp.IsCurrent = false;
|
|
||||||
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseExp2 = await context.Experiences.FirstOrDefaultAsync(e => e.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseExp2);
|
|
||||||
Assert.AreEqual("Software Engineer II", inBaseExp2.Title);
|
|
||||||
Assert.AreEqual("CGI II", inBaseExp2.CompanyName);
|
|
||||||
Assert.AreEqual(new DateTime(2021, 9, 1), inBaseExp2.StartDate);
|
|
||||||
Assert.AreEqual(new DateTime(2023, 6, 1), inBaseExp2.EndDate);
|
|
||||||
Assert.IsFalse(inBaseExp2.IsCurrent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ToString_ReturnsCorrectFormat()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var experience = new ExperienceEntity
|
|
||||||
{
|
|
||||||
Id = "100",
|
|
||||||
Title = "Software Engineer",
|
|
||||||
CompanyName = "CGI",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = experience.ToString();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var expected = "\tTitle: Software Engineer, Company: CGI, Start Date: 01/09/2020, End Date: 01/06/2022, Is Current: True";
|
|
||||||
Assert.AreEqual(expected, result);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace UnitTestEF.Entities;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Infrastructure;
|
|
||||||
using Infrastructure.Entities;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class FormationTest
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public async Task AddFormationTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newFormation = new FormationEntity {
|
|
||||||
Id = "100",
|
|
||||||
SchoolName = "IUT",
|
|
||||||
Name = "BUT Informatique",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
await context.Formations.AddAsync(newFormation);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseFormation = await context.Formations.FirstOrDefaultAsync(f => f.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseFormation);
|
|
||||||
Assert.AreEqual("100", inBaseFormation.Id);
|
|
||||||
Assert.AreEqual("IUT", inBaseFormation.SchoolName);
|
|
||||||
Assert.AreEqual("BUT Informatique", inBaseFormation.Name);
|
|
||||||
Assert.AreEqual(new DateTime(2020, 9, 1), inBaseFormation.StartDate);
|
|
||||||
Assert.AreEqual(new DateTime(2022, 6, 1), inBaseFormation.EndDate);
|
|
||||||
Assert.IsTrue(inBaseFormation.IsCurrent);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task DeleteFormationTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newFormation = new FormationEntity {
|
|
||||||
Id = "100",
|
|
||||||
SchoolName = "IUT",
|
|
||||||
Name = "BUT Informatique",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
await context.Formations.AddAsync(newFormation);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseFormation = await context.Formations.FirstOrDefaultAsync(f => f.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseFormation);
|
|
||||||
|
|
||||||
context.Formations.Remove(newFormation);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var formationAfterDelete = await context.Formations.FirstOrDefaultAsync(f => f.Id == "100");
|
|
||||||
Assert.IsNull(formationAfterDelete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task UpdateFormationTest()
|
|
||||||
{
|
|
||||||
var connection = new SqliteConnection("DataSource=:memory:");
|
|
||||||
connection.Open();
|
|
||||||
var options = new DbContextOptionsBuilder<AlumniDbContext>()
|
|
||||||
.UseSqlite(connection)
|
|
||||||
.Options;
|
|
||||||
using (var context = new AlumniDbContext(options))
|
|
||||||
{
|
|
||||||
context.Database.EnsureDeleted();
|
|
||||||
context.Database.EnsureCreated();
|
|
||||||
var newFormation = new FormationEntity {
|
|
||||||
Id = "100",
|
|
||||||
SchoolName = "IUT",
|
|
||||||
Name = "BUT Informatique",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
await context.Formations.AddAsync(newFormation);
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var inBaseFormation = await context.Formations.FirstOrDefaultAsync(f => f.Id == "100");
|
|
||||||
Assert.IsNotNull(inBaseFormation);
|
|
||||||
|
|
||||||
inBaseFormation.SchoolName = "IUT2";
|
|
||||||
inBaseFormation.Name = "BUT Informatique2";
|
|
||||||
inBaseFormation.StartDate = new DateTime(2020, 9, 2);
|
|
||||||
inBaseFormation.EndDate = new DateTime(2022, 6, 2);
|
|
||||||
inBaseFormation.IsCurrent = false;
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var formationAfterUpdate = await context.Formations.FirstOrDefaultAsync(f => f.Id == "100");
|
|
||||||
Assert.IsNotNull(formationAfterUpdate);
|
|
||||||
Assert.AreEqual("IUT2", formationAfterUpdate.SchoolName);
|
|
||||||
Assert.AreEqual("BUT Informatique2", formationAfterUpdate.Name);
|
|
||||||
Assert.AreEqual(new DateTime(2020, 9, 2), formationAfterUpdate.StartDate);
|
|
||||||
Assert.AreEqual(new DateTime(2022, 6, 2), formationAfterUpdate.EndDate);
|
|
||||||
Assert.IsFalse(formationAfterUpdate.IsCurrent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ToString_ReturnsCorrectFormat()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var formation = new FormationEntity
|
|
||||||
{
|
|
||||||
Id = "100",
|
|
||||||
SchoolName = "IUT",
|
|
||||||
Name = "BUT Informatique",
|
|
||||||
StartDate = new DateTime(2020, 9, 1),
|
|
||||||
EndDate = new DateTime(2022, 6, 1),
|
|
||||||
IsCurrent = true
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = formation.ToString();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var expected = "\tFormation : BUT Informatique \tSchool's name : IUT";
|
|
||||||
Assert.AreEqual(expected, result);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue