Compare commits

..

80 Commits

Author SHA1 Message Date
Lucas DELANIER d61badd2c1 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 43e79ad879 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 30006c2a05 merge EF master
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 9d5bb44db7 merge EF
2 years ago
Louison PARANT 954a5beaf4 merge
2 years ago
Lucas Delanier 320af91c4d Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier ec30c62a53 ut
2 years ago
Lucas DELANIER 6ad3d04bfc Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 85f983101b Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 2375d451ac Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 977038d6e1 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER c3bf8ae799 Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 759fb1d702 Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 466e5d1742 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 86db87a6b4 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 9c510c1169 Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER d3a6115aab Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 9d9d1633e9 Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 740c953f3d update v2
2 years ago
Lucas DELANIER 9e060e989c Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT b343313730 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT d6e1228511 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT d10e81e08b Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 5b561762aa Supprimer 'Documentations/Group 13.png'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT ccb1ebea3f Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT b0200bf1a9 Supprimer 'Mask group.png'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 5a3155e5a9 Transférer les fichiers vers ''
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER ed176bd5d7 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 931860ad0e Push EFManager
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 429aacf744 Mise à jour de 'README.md'
2 years ago
Lucas DELANIER a6915bff52 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 65a211fd85 test ci
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier f0e9f43284 Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 55447bf403 push
2 years ago
Louison PARANT 360c84ed35 Finished DB
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT bce3933e33 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 8ddb7d39a8 Mise à jour de 'README.md'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier c14dd95142 push merge
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT e071376f80 Add Entities and EFManagers
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 1dcd5db1fc Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 78c79cfea1 merge master
2 years ago
Lucas DELANIER 42be77e907 Transférer les fichiers vers 'Documentations'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 2dd3fd8088 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 61524f2bb0 Mise à jour de 'README.md'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 920efc3bec Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier 306d637b53 test ignored
continuous-integration/drone/push Build is passing Details
2 years ago
Louison PARANT 17718682ad Fusion EFManager
2 years ago
Lucas Delanier 66f7fd10b7 solve error pageresponse
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier fbbc8d036a modif
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 3fc3ddff6c Push Modif EF + Manager EF (manque modif Mapper à pull)
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 652d47c40e finishh pagination
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 70fa29f29a add attribu to championdto
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 60e7cf0762 unit test
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas Delanier c5cf2e0bb6 new controllers
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT 096dc87b5f API Skill (Mapper+Controller)
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 0673268745 finish crud champio and start skin crud
continuous-integration/drone/push Build is failing Details
2 years ago
Louison PARANT ecd16624b8 Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
continuous-integration/drone/push Build is passing Details
2 years ago
Louison PARANT ab8fde8b44 push bdd (manque plus que dicos)
2 years ago
Lucas DELANIER ba61ba7785 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is passing Details
2 years ago
Lucas DELANIER 69afed7f2f Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 6bd4f5b3ad Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier cce933a3aa test docker
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier 2e4afe7196 Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas Delanier f15d5814cf fix dtoMerge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
2 years ago
Lucas DELANIER eed1124b59 Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER c2b926aa1d Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER 2b88c9c9ae Mise à jour de '.drone.yml'
continuous-integration/drone/push Build is failing Details
2 years ago
Lucas DELANIER ccac0e374c Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas DELANIER 9f6c34532e Mise à jour de '.drone.yml'
continuous-integration/drone/push Build encountered an error Details
2 years ago
Lucas Delanier 9c4c3637a3 Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
2 years ago
Lucas Delanier 937d6ddefe DOCKERFILE
2 years ago
Lucas DELANIER 46e9f76669 Mise à jour de '.drone.yml'
2 years ago
Lucas DELANIER 1b17d93362 Mise à jour de '.drone.yml'
2 years ago
Lucas DELANIER 38afc66b3f Ajouter '.drone.yml'
2 years ago
Louison PARANT b5d8d82ad7 push bdd (v2 tjr pas dico ni skill)
2 years ago
Louison PARANT 12b0acc1a9 push Bdd (sauf dico et skill)
2 years ago
Louison PARANT 6650ce89e0 push EF database
2 years ago
Louison PARANT 14cec510d4 Merge branch 'master' of https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject
2 years ago
Lucas Delanier d566a76284 conflit
2 years ago
Lucas Delanier 62387e36f5 add unit test
2 years ago

@ -0,0 +1,84 @@
kind: pipeline
type: docker
name: default
trigger:
event:
- push
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
volumes:
- name: docs
path: /docs
commands:
- cd Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet build LeagueOfLegends.sln -c Release --no-restore
- dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- name: tests
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- cd Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet test LeagueOfLegends.sln --no-restore
depends_on: [build]
- name: code-analysis
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6
commands:
- cd Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet sonarscanner begin /k:LOLProject /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
- dotnet build LeagueOfLegends.sln -c Release --no-restore
- dotnet test LeagueOfLegends.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
- reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
- dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
- dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN}
secrets: [ SONAR_TOKEN ]
settings:
sonar_host: https://codefirst.iut.uca.fr/sonar/
sonar_token:
from_secret: SONAR_TOKEN
depends_on: [tests]
- name: generate-and-deploy-docs
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
failure: ignore
volumes:
- name: docs
path: /docs
commands:
#- cd Documentation/doxygen
#- doxygen Doxyfile
- /entrypoint.sh
when:
branch:
- master
depends_on: [ build ]
# docker image build
- name: docker-build-and-push
image: plugins/docker
settings:
dockerfile: Sources/APILOL/Dockerfile
context: Sources/
registry: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6
repo: hub.codefirst.iut.uca.fr/lucas.delanier/lolproject
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
# container deployment
- name: deploy-container
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/lucas.delanier/lolproject:latest
CONTAINERNAME: containerlol
COMMAND: create
OVERWRITE: true
volumes:
- name: docs
temp: {}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

@ -1,168 +1,97 @@
# prepaLoL
## Diagramme de classes du modèle
```mermaid
classDiagram
class LargeImage{
+/Base64 : string
}
class Champion{
+/Name : string
+/Bio : string
+/Icon : string
+/Characteristics : Dictionary~string, int~
~ AddSkin(skin : Skin) bool
~ RemoveSkin(skin: Skin) bool
+ AddSkill(skill: Skill) bool
+ RemoveSkill(skill: Skill) bool
+ AddCharacteristics(someCharacteristics : params Tuple~string, int~[])
+ RemoveCharacteristics(label : string) bool
+ this~label : string~ : int?
}
Champion --> "1" LargeImage : Image
class ChampionClass{
<<enumeration>>
Unknown,
Assassin,
Fighter,
Mage,
Marksman,
Support,
Tank,
}
Champion --> "1" ChampionClass : Class
class Skin{
+/Name : string
+/Description : string
+/Icon : string
+/Price : float
}
Skin --> "1" LargeImage : Image
Champion "1" -- "*" Skin
class Skill{
+/Name : string
+/Description : string
}
class SkillType{
<<enumeration>>
Unknown,
Basic,
Passive,
Ultimate,
}
Skill --> "1" SkillType : Type
Champion --> "*" Skill
class Rune{
+/Name : string
+/Description : string
}
Rune --> "1" LargeImage : Image
class RuneFamily{
<<enumeration>>
Unknown,
Precision,
Domination
}
Rune --> "1" RuneFamily : Family
class Category{
<<enumeration>>
Major,
Minor1,
Minor2,
Minor3,
OtherMinor1,
OtherMinor2
}
class RunePage{
+/Name : string
+/this[category : Category] : Rune?
- CheckRunes(newRuneCategory : Category)
- CheckFamilies(cat1 : Category, cat2 : Category) bool?
- UpdateMajorFamily(minor : Category, expectedValue : bool)
}
RunePage --> "*" Rune : Dictionary~Category,Rune~
```
## Diagramme de classes des interfaces de gestion de l'accès aux données
```mermaid
classDiagram
direction LR;
class IGenericDataManager~T~{
<<interface>>
GetNbItems() Task~int~
GetItems(index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~T~~
GetNbItemsByName(substring : string)
GetItemsByName(substring : string, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~T~~
UpdateItem(oldItem : T, newItem : T) Task~T~~
AddItem(item : T) Task~T~
DeleteItem(item : T) Task~bool~
}
class IChampionsManager{
<<interface>>
GetNbItemsByCharacteristic(charName : string)
GetItemsByCharacteristic(charName : string, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Champion?~~
GetNbItemsByClass(championClass : ChampionClass)
GetItemsByClass(championClass : ChampionClass, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Champion?~~
GetNbItemsBySkill(skill : Skill?)
GetItemsBySkill(skill : Skill?, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Champion?~~
GetNbItemsBySkill(skill : string)
GetItemsBySkill(skill : string, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Champion?~~
GetNbItemsByRunePage(runePage : RunePage?)
GetItemsByRunePage(runePage : RunePage?, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Champion?~~
}
class ISkinsManager{
<<interface>>
GetNbItemsByChampion(champion : Champion?)
GetItemsByChampion(champion : Champion?, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Skin?~~
}
class IRunesManager{
<<interface>>
GetNbItemsByFamily(family : RuneFamily)
GetItemsByFamily(family : RuneFamily, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~Rune?~~
}
class IRunePagesManager{
<<interface>>
GetNbItemsByRune(rune : Rune?)
GetItemsByRune(rune : Rune?, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~RunePage?~~
GetNbItemsByChampion(champion : Champion?)
GetItemsByChampion(champion : Champion?, index : int, count : int, orderingPropertyName : string?, descending : bool) Task~IEnumerable~RunePage?~~
}
IGenericDataManager~Champion?~ <|.. IChampionsManager : T--Champion?
IGenericDataManager~Skin?~ <|.. ISkinsManager : T--Skin?
IGenericDataManager~Rune?~ <|.. IRunesManager : T--Rune?
IGenericDataManager~RunePage?~ <|.. IRunePagesManager : T--RunePage?
class IDataManager{
<<interface>>
}
IChampionsManager <-- IDataManager : ChampionsMgr
ISkinsManager <-- IDataManager : SkinsMgr
IRunesManager <-- IDataManager : RunesMgr
IRunePagesManager <-- IDataManager : RunePagesMgr
```
## Diagramme de classes simplifié du Stub
```mermaid
classDiagram
direction TB;
IDataManager <|.. StubData
ChampionsManager ..|> IChampionsManager
StubData --> ChampionsManager
RunesManager ..|> IRunesManager
StubData --> RunesManager
RunePagesManager ..|> IRunePagesManager
StubData --> RunePagesManager
SkinsManager ..|> ISkinsManager
StubData --> SkinsManager
StubData --> RunesManager
StubData --> "*" Champion
StubData --> "*" Rune
StubData --> "*" RunePages
StubData --> "*" Skins
```
## LOLProject
**LOLProject** est un projet reliant une API C# et EntityFramework afin de produire une API qui renvoie les informations d'une base de données SQLite sur un client MAUI
Merci de noter la v1 de l'api qui est tenu a jour la v2 sert uniquement a montrer que nous pouvons versionner.
## :floppy_disk: FEATURES
- L'API dispose des principales requêtes CRUD sur les champions, skills, skins, runes, runepages aussi consultables sur le swagger UI.
- L'ORM réalisé avec EntityFramework afin d'enregistrer dans une base de données SQLite
- L'application MAUI pour faire des requêtes depuis un client et les afficher.
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
## :dizzy: Getting Started
Une fois le dépot cloné, vous pouvez lancer le code sur votre téléphone Android grâce à l'outil Android Studio ou grâce à un émulateur Android.
## Architecture
![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Schema_architecture.png)
Ce schéma d'architecure globale permet de comprendre la composition interne de la solution.
Sur la partie gauche on peut voir la partie client qui fait appel a l'api via des requetes http en utilisant les routes de l'api Rest Full.
Pour tout a fait comprendre, comment communiquent et fonctionnent les différentes briques de la solution nous allons vous détailler brique par brique, relation par relation les différentes point rouge du schéma.
## 1 - La déserialization
Le client est une solution qui va intérragir avec notre api grace des requetes sur internet. Il nécessite donc impérativement d'une connexion internet afin de pouvoir communiquer grace a des requetes http(s). Une fois qu'il a récupéré les données demandé. Il doit transoformer ce document json en classe métier de son model. Cela s'appel la déserialization. Ce processus ce traduit ar le code suivant en C#.
![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Capture%20d%27%C3%A9cran%202023-03-26%20111526.png)
## 2 - La communication Client - Api
Maintenant que vous savez comment le client traite les données renvoyées par l'API, nous allons a présent voir comment ils communiquent entre eux. Cette communication se fait par des requetes http(s) sous la forme suivante.
"codefirst.iut.uca.fr/containers/lucasdelanier-containerlol/api/v{version}/{controller}"
Lors de l'appel de l'API, le client peut choisir la version ( v1, v2, etc) mais aussi indiquer le controlleur qu'il souhaite intérroger. Par exemple Champion lui permettra de récuperer des informations sur les champions que connait l'API. Il est aussi possible de rajouter de précisions en ajoutant par exemple un nom apres le controller pour demander les informations spécifique a un champion en particulié. Lors des communications, les objects sons traduit sous la forme DTO. Cela permet de controller l'envoie de certaines données au client comme pr exemple un id unique ou des données sensibles qui ne doivent pas etre connu par l'utilisateur. Voici un exemple.
![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Capture%20d%27%C3%A9cran%202023-03-26%20113439.png)
Ci dessus on voit que l'object champion a une nouvelle "forme" ChampionDTO que l'on construit a partir des attributs d'un champion. Dans l'exemple, il reprend les memes informations qu'un champion mais on aurait put imaginer qu'il en perde certains que l'on ne veut pas renvoyer a l'utilisateur. Pour permettre le passage d'un DTO en object et d'un object en DTO il faut ce qu'on appel des Mappers. Voici l'exemple des méthodes ToModel() et ToDTO()
![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Capture%20d%27%C3%A9cran%202023-03-26%20113710.png)
## 3 - L'utilisation du stub dans l'API
Avant de faire la relation avec une base de données. Il était impotant de pouvoir tester l'application avec un Stub qui est une classe contenant des listes d'object. Une sorte de base de données fictive. Pour permettre a l'api d'intéroger ce stub, il a fallut faire un manager spécialement destiné à l'utilisation du stub (StubData) qui hérite d'un manager commun qui est une interface composé des méthodes nécessaire a l'interrogation des données (IDataManager).
![](https://codefirst.iut.uca.fr/git/lucas.delanier/LOLProject/raw/branch/master/Documentations/Capture%20d%27%C3%A9cran%202023-03-26%20114811.png)
## 4 - Lien entre API et Entityframework
Pour relier l'API avec la partie EntityFramework, cela se passe du côté de l'API. En effet, en ayant implémenter des managers en EntityFramework, il suffit de les instancier côté API puis de demander la requête adéquate pour obtenir les données de la base de données avec l'API. Ces managers regroupent plusieurs petits managers gérant chacun une entité de la base de données (Champion, RunePage, Rune, ...). Il n'y a pas de managers de Skill car ceux-ci sont compris dans le manager Champion (un peu comme les mappers côté API).
## 5 - Mappage des classes métier en tables
Afin de rentrer les classes métiers en base de données, il faut avant tout les mapper. Ainsi, il y a un mapper pour chaque entité de la base de données (même pour Skill par exemple). Ensuite, il faut deux méthodes pour chaque mapper :
<br> 1- ToEntity : elle prend en paramètre un objet du modèle et permet de le transformer en entité afin de pouvoir l'insérer en base de données.
<br> 2- ToModel : elle prend en paramètre une entité et permet de la transformer en objet.
Grâce à ces deux méthodes, nous pouvons facilement mapper des entités en objet et inversement.
## 6 - Lien avec base de données SQLite
Il y a deux manières d'utiliser la base de données SQLite. On peut soit, utiliser la base de données interne à l'appareil ou bien utiliser la mémoire de l'appareil pour sauvegarder les données en local. Pour créer la base, il faut avoir des classes entités représentant chacune une table de la base. Il peut aussi y avoir des entités représentant des liaisons entre deux tables (RunePageRuneEntity par exemple représente la table entre RunePage et Rune). Ensuite, il faut un contexte (SQLiteContext pour notre projet) qui a pour attributs des DbSets, des listes d'entités à mettre en base de données. Pour remplir la base de données, avec un Stub par exemple, on peut utiliser la méthode onCreate du contexte pour insérer des entités créees manuellement. Cependant, pour mettre des objets en base, il faut donc les mapper en entité puis, passer par un manager (dans notre cas) pour enfin le rentrer en base.
## :wrench: SUPPORT
En cas de problème lors de l'utilisation de l'application, vous pouvez nous contacter aux adresses suivantes :
Lucas Delanier : **Lucas.DELANIER@etu.uca.fr** </br>
Louison Parant : **Louison.PARANT@etu.uca.fr**
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
## ✨ Contributors
<a href = "https://codefirst.iut.uca.fr/git/lucas.delanier">
<img src ="https://codefirst.iut.uca.fr/git/avatars/6a3835d734392fccff3949f7c82a63b9?size=870" height="50px">
</a>
<a href = "https://codefirst.iut.uca.fr/git/louison.parant">
<img src ="https://codefirst.iut.uca.fr/git/avatars/b337a607f680a2d9af25eb09ea457be9?size=870" height="50px">
</a>

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

@ -1,12 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>036530f1-7b72-4f69-a1a3-0b4039b6a80a</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
@ -14,11 +17,15 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.Core" Version="5.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\EntityFrameworkLOL\EntityFrameworkLOL.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>

@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace APILOL
{
public class ConfigureSwaggerGenOptions : IConfigureOptions<SwaggerGenOptions>
{
private readonly IApiVersionDescriptionProvider _apiVersionDescriptionProvider;
public ConfigureSwaggerGenOptions(IApiVersionDescriptionProvider apiVersionDescriptionProvider)
=> _apiVersionDescriptionProvider = apiVersionDescriptionProvider;
public void Configure(SwaggerGenOptions options)
{
foreach (var description in _apiVersionDescriptionProvider.ApiVersionDescriptions)
{
options.SwaggerDoc(description.GroupName, CreateOpenApiInfo(description));
}
}
private static OpenApiInfo CreateOpenApiInfo(ApiVersionDescription description)
{
var info = new OpenApiInfo()
{
Title = "LSE.Stocks.API",
Version = description.ApiVersion.ToString()
};
if (description.IsDeprecated)
{
info.Description += " (deprecated)";
}
return info;
}
}
}

@ -12,48 +12,60 @@ namespace APILOL.Controllers
[ApiController]
public class ChampionsController : ControllerBase
{
IChampionsManager dataManager = new StubData().ChampionsMgr;
IChampionsManager dataManager;
public ChampionsController(IDataManager dataManager)
{
this.dataManager = dataManager.ChampionsMgr;
}
// GET: api/<ChampionController>
[HttpGet]
public async Task<IActionResult> Get()
public async Task<IActionResult> Get(int index, int count)
{
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems());
return Ok(new { result = champions.Select(c => c.ToDto())});
var champions = await dataManager.GetItems(index, count);
IEnumerable<ChampionDTO> items = champions.Select(c => c.ToDto());
return Ok(items);
}
// GET api/<ChampionController>/5
[HttpGet("{name}")]
public IActionResult Get(string name)
public async Task<IActionResult> Get(string name)
{
if (dataManager.GetNbItemsByName(name) != null)
{
return Ok(dataManager.GetItemsByName(name, 0, dataManager.GetNbItemsByName(name)));
return Ok(dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
}
return NotFound();
}
// POST api/<ChampionController>
[HttpPost]
public void Post([FromBody] ChampionDTO championDTO)
public async Task<IActionResult> Post([FromBody] ChampionDTO championDTO)
{
return CreatedAtAction(nameof(Get),(await dataManager.AddItem(championDTO.ToModel())).ToDto);
}
// PUT api/<ChampionController>/5
[HttpPut("{name}")]
public void Put(string name, [FromBody] ChampionDTO championDTO)
public async Task<IActionResult> PutAsync(string name, [FromBody] ChampionDTO championDTO)
{
var dtos = (await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
return Ok(dataManager.UpdateItem(dtos.First(), championDTO.ToModel()));
}
// DELETE api/<ChampionController>/5
[HttpDelete("{name}")]
public void Delete(string name)
public async Task<IActionResult> Delete(string name)
{
var dtos = (await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
return Ok(dataManager.DeleteItem(dtos.First()));
}
}
}
/*
var champion = new Champion("");
var dto = ChampionMapper.ToDto(champion);
*/
}

@ -0,0 +1,13 @@
namespace APILOL.Controllers.Request
{
public class PageRequest
{
public bool IsDesc { get; set; } = false;
public int Offset { get; set; } = 0;
public string? OrderingPropertyName { get; set; } = "Name";
public int Limit { get; set; } = 10;
}
}

@ -0,0 +1,184 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using System.Xml.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers.v1
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class ChampionsController : ControllerBase
{
IChampionsManager dataManager;
private readonly ILogger<ChampionsController> _logger;
public ChampionsController(IDataManager dataManager, ILogger<ChampionsController> logger)
{
this.dataManager = dataManager.ChampionsMgr;
this._logger = logger;
}
// GET: api/<ChampionController>
[MapToApiVersion("1.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - CHAMPION ");
try
{
var total = await dataManager.GetNbItems();
var champions = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<ChampionDTO> items = champions.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogError("No champion found.");
return NotFound("No champion found.");
}
return Ok(new {data= items,count= await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit});
}
catch(Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// GET api/<ChampionController>/5
[MapToApiVersion("1.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request,string name)
{
_logger.LogInformation("API call - [GET / NAME] - CHAMPION {name}", name);
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var champions = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable <ChampionDTO> items = champions.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogError("No champion found.");
return NotFound("No champion found.");
}
return Ok(new {data= items,count= dataManager.GetNbItems()});
}
return NotFound("No champion matching with this name.");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// POST api/<ChampionController>
[MapToApiVersion("1.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] ChampionDTO championDTO)
{
_logger.LogInformation("API call - [POST] - CHAMPION");
try
{
if(await dataManager.GetNbItemsByName(championDTO.Name) == 0)
{
await dataManager.AddItem(championDTO.ToModel());
return CreatedAtAction(nameof(Get), championDTO);
}
_logger.LogError("A champion already exist with this Name. ( Unique Name )");
return BadRequest("A champion already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<ChampionController>/5
[MapToApiVersion("1.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] ChampionDTO championDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - CHAMPION");
try
{
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(champion.First().Name) ;
var champion2 = await dataManager
.GetItemsByName(championDTO.Name, 0, await dataManager.GetNbItems());
if (champion != null)
{
if(champion2.Count() == 0)
{
await dataManager.UpdateItem(champion.First(), championDTO.ToModel());
return Ok();
}
_logger.LogError("champion already exist with this unique name.");
return BadRequest("champion already exist with this unique name.");
}
else
{
_logger.LogError("champion not found.");
return NotFound("champion not found.");
}
await dataManager.UpdateItem(champion.First(), championDTO.ToModel());
return Ok();
}
catch (Exception e)
{
_logger.LogInformation("Error in the request");
return BadRequest(e.Message);
}
}
// DELETE api/<ChampionController>/5
[MapToApiVersion("1.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - CHAMPION");
try
{
var champion = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (champion.Count() != 0)
{
var championDto = champion.First().ToDto();
await dataManager.DeleteItem(champion.First());
return Ok(championDto);
}
else
{
_logger.LogError("No matching Champion with this name");
return NotFound("No matching Champion with this name");
}
}
catch(Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error);
}
}
}
}

@ -0,0 +1,178 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers.v1
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class RuneController : ControllerBase
{
IRunesManager dataManager;
private readonly ILogger<RuneController> _logger;
public RuneController(IDataManager dataManager, ILogger<RuneController> logger)
{
this.dataManager = dataManager.RunesMgr;
this._logger = logger;
}
// GET: api/<RuneController>
[MapToApiVersion("1.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - RUNE");
try
{
var total = await dataManager.GetNbItems();
var runes = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RuneDTO> items = runes.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No rune found.");
return NotFound("No rune found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// GET api/<RuneController>/5
[MapToApiVersion("1.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - RUNE");
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var runes = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RuneDTO> items = runes.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No rune found.");
return BadRequest("No rune found.");
}
return Ok(items);
}
return NotFound("No rune matching with this name.");
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// POST api/<RuneController>
[MapToApiVersion("1.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] RuneDTO runeDTO)
{
_logger.LogInformation("API call - [POST] - RUNE");
try
{
if (await dataManager.GetNbItemsByName(runeDTO.Name) == 0)
{
await dataManager.AddItem(runeDTO.ToModel());
return CreatedAtAction(nameof(Get), runeDTO);
}
_logger.LogInformation("A rune already exist with this Name. ( Unique Name )");
return BadRequest("A rune already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<Rune>/5
[MapToApiVersion("1.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] RuneDTO runeDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - RUNE");
try
{
var rune = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(rune.First().Name);
var rune2 = await dataManager
.GetItemsByName(runeDTO.Name, 0, await dataManager.GetNbItems());
if (rune != null)
{
if (rune2.Count() == 0)
{
await dataManager.UpdateItem(rune.First(), runeDTO.ToModel());
return Ok();
}
_logger.LogInformation("rune already exist with this unique name.");
return BadRequest("rune already exist with this unique name.");
}
else
{
_logger.LogInformation("rune not found.");
return NotFound("rune not found.");
}
await dataManager.UpdateItem(rune.First(), runeDTO.ToModel());
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<RuneController>/5
[MapToApiVersion("1.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - RUNE");
try
{
var rune = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (rune.Count() != 0)
{
var runeDto = rune.First().ToDto();
await dataManager.DeleteItem(rune.First());
return Ok(runeDto);
}
else
{
_logger.LogInformation("No matching rune with this name");
return NotFound("No matching rune with this name");
}
}
catch (Exception error)
{
return BadRequest(error);
}
}
}
}

@ -0,0 +1,183 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers.v1
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class RunePageController : ControllerBase
{
IRunePagesManager dataManager;
private readonly ILogger<RunePageController> _logger;
public RunePageController(IDataManager dataManager, ILogger<RunePageController> logger)
{
this.dataManager = dataManager.RunePagesMgr;
this._logger = logger;
}
// GET: api/<RunePageController>
[MapToApiVersion("1.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - RUNEPAGE");
try
{
var total = await dataManager.GetNbItems();
var runePages = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RunePageDTO> items = runePages.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No runePage found.");
return NotFound("No runePage found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// GET api/<RunePageController>/5
[MapToApiVersion("1.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - RUNEPAGE");
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var runepages = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RunePageDTO> items = runepages.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No runePage found.");
return NotFound("No runePage found.");
}
return Ok(items);
}
return NotFound("No runePage matching with this name.");
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// POST api/<RunePageController>
[MapToApiVersion("1.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] RunePageDTO runePageDTO)
{
_logger.LogInformation("API call - [POST] - RUNEPAGE");
try
{
if (await dataManager.GetNbItemsByName(runePageDTO.Name) == 0)
{
await dataManager.AddItem(runePageDTO.ToModel());
return CreatedAtAction(nameof(Get), runePageDTO);
}
_logger.LogInformation("A runePage already exist with this Name. ( Unique Name )");
return BadRequest("A runePage already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<RunePage>/5
[MapToApiVersion("1.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] RunePageDTO runePageDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - RUNEPAGE");
try
{
var runePage = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(runePage.First().Name);
var runePage2 = await dataManager
.GetItemsByName(runePageDTO.Name, 0, await dataManager.GetNbItems());
if (runePage != null)
{
if (runePage2.Count() == 0)
{
await dataManager.UpdateItem(runePage.First(), runePageDTO.ToModel());
return Ok();
}
_logger.LogInformation("runePage already exist with this unique name.");
return BadRequest("runePage already exist with this unique name.");
}
else
{
_logger.LogInformation("runePage not found.");
return NotFound("runePage not found.");
}
await dataManager.UpdateItem(runePage.First(), runePageDTO.ToModel());
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<RunePageController>/5
[MapToApiVersion("1.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - RUNEPAGE");
try
{
var runePage = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (runePage.Count() != 0)
{
var runePageDto = runePage.First().ToDto();
await dataManager.DeleteItem(runePage.First());
return Ok(runePageDto);
}
else
{
_logger.LogInformation("No matching runePage with this name");
return NotFound("No matching runePage with this name");
}
}
catch (Exception error)
{
return BadRequest(error);
}
}
}
}
/*
var champion = new Champion("");
var dto = ChampionMapper.ToDto(champion);
*/

@ -0,0 +1,176 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
namespace APILOL.Controllers.v1
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class SkinController : ControllerBase
{
ISkinsManager dataManager;
private readonly ILogger<SkinController> _logger;
public SkinController(IDataManager dataManager, ILogger<SkinController> logger)
{
this.dataManager = dataManager.SkinsMgr;
this._logger = logger;
}
// GET: api/<SkinController>
[MapToApiVersion("1.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - SKIN");
try
{
var total = await dataManager.GetNbItems();
var skins = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<SkinDTO> items = skins.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No skin found.");
return NotFound("No skin found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// GET api/<SkinController>/5
[MapToApiVersion("1.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - SKIN");
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var skins = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<SkinDTO> items = skins.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No Skin found.");
return NotFound("No Skin found.");
}
return Ok(items);
}
return NotFound("No Skin matching with this name.");
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// POST api/<SkinController>
[MapToApiVersion("1.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] SkinDTO skinDTO)
{
_logger.LogInformation("API call - [POST] - SKIN");
try
{
if (await dataManager.GetNbItemsByName(skinDTO.Name) == 0)
{
await dataManager.AddItem(skinDTO.ToModel());
return CreatedAtAction(nameof(Get), skinDTO);
}
_logger.LogInformation("A Skin already exist with this Name. ( Unique Name )");
return BadRequest("A Skin already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<Skin>/5
[MapToApiVersion("1.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] SkinDTO skinDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - SKIN");
try
{
var skin = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(skin.First().Name);
var skin2 = await dataManager
.GetItemsByName(skinDTO.Name, 0, await dataManager.GetNbItems());
if (skin != null)
{
if (skin2.Count() == 0)
{
await dataManager.UpdateItem(skin.First(), skinDTO.ToModel());
return Ok();
}
_logger.LogInformation("Skin already exist with this unique name.");
return BadRequest("Skin already exist with this unique name.");
}
else
{
_logger.LogInformation("Skin not found.");
return NotFound("Skin not found.");
}
await dataManager.UpdateItem(skin.First(), skinDTO.ToModel());
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<SkinController>/5
[MapToApiVersion("1.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - SKIN");
try
{
var skin = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (skin.Count() != 0)
{
var skinDto = skin.First().ToDto();
await dataManager.DeleteItem(skin.First());
return Ok(skinDto);
}
else
{
_logger.LogInformation("No matching skin with this name");
return NotFound("No matching skin with this name");
}
}
catch (Exception error)
{
return BadRequest(error);
}
}
}
}

@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Mvc;
namespace APILOL.Controllers.v1
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
[MapToApiVersion("1.0")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

@ -0,0 +1,184 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using System.Xml.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers.v2
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("2.0")]
public class ChampionsController : ControllerBase
{
IChampionsManager dataManager;
private readonly ILogger<ChampionsController> _logger;
public ChampionsController(IDataManager dataManager, ILogger<ChampionsController> logger)
{
this.dataManager = dataManager.ChampionsMgr;
this._logger = logger;
}
// GET: api/<ChampionController>
[MapToApiVersion("2.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - CHAMPION ");
try
{
var total = await dataManager.GetNbItems();
var champions = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<ChampionDTO> items = champions.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogError("No champion found.");
return NotFound("No champion found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// GET api/<ChampionController>/5
[MapToApiVersion("2.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - CHAMPION {name}", name);
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var champions = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<ChampionDTO> items = champions.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogError("No champion found.");
return NotFound("No champion found.");
}
return Ok(new { data = items, count = dataManager.GetNbItems() });
}
return NotFound("No champion matching with this name.");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// POST api/<ChampionController>
[MapToApiVersion("2.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] ChampionDTO championDTO)
{
_logger.LogInformation("API call - [POST] - CHAMPION");
try
{
if (await dataManager.GetNbItemsByName(championDTO.Name) == 0)
{
await dataManager.AddItem(championDTO.ToModel());
return CreatedAtAction(nameof(Get), championDTO);
}
_logger.LogError("A champion already exist with this Name. ( Unique Name )");
return BadRequest("A champion already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<ChampionController>/5
[MapToApiVersion("2.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] ChampionDTO championDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - CHAMPION");
try
{
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(champion.First().Name);
var champion2 = await dataManager
.GetItemsByName(championDTO.Name, 0, await dataManager.GetNbItems());
if (champion != null)
{
if (champion2.Count() == 0)
{
await dataManager.UpdateItem(champion.First(), championDTO.ToModel());
return Ok();
}
_logger.LogError("champion already exist with this unique name.");
return BadRequest("champion already exist with this unique name.");
}
else
{
_logger.LogError("champion not found.");
return NotFound("champion not found.");
}
await dataManager.UpdateItem(champion.First(), championDTO.ToModel());
return Ok();
}
catch (Exception e)
{
_logger.LogInformation("Error in the request");
return BadRequest(e.Message);
}
}
// DELETE api/<ChampionController>/5
[MapToApiVersion("2.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - CHAMPION");
try
{
var champion = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (champion.Count() != 0)
{
var championDto = champion.First().ToDto();
await dataManager.DeleteItem(champion.First());
return Ok(championDto);
}
else
{
_logger.LogError("No matching Champion with this name");
return NotFound("No matching Champion with this name");
}
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error);
}
}
}
}

@ -0,0 +1,178 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers.v2
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("2.0")]
public class RuneController : ControllerBase
{
IRunesManager dataManager;
private readonly ILogger<RuneController> _logger;
public RuneController(IDataManager dataManager, ILogger<RuneController> logger)
{
this.dataManager = dataManager.RunesMgr;
this._logger = logger;
}
// GET: api/<RuneController>
[MapToApiVersion("2.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - RUNE");
try
{
var total = await dataManager.GetNbItems();
var runes = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RuneDTO> items = runes.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No rune found.");
return NotFound("No rune found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// GET api/<RuneController>/5
[MapToApiVersion("2.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - RUNE");
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var runes = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RuneDTO> items = runes.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No rune found.");
return BadRequest("No rune found.");
}
return Ok(items);
}
return NotFound("No rune matching with this name.");
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// POST api/<RuneController>
[MapToApiVersion("2.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] RuneDTO runeDTO)
{
_logger.LogInformation("API call - [POST] - RUNE");
try
{
if (await dataManager.GetNbItemsByName(runeDTO.Name) == 0)
{
await dataManager.AddItem(runeDTO.ToModel());
return CreatedAtAction(nameof(Get), runeDTO);
}
_logger.LogInformation("A rune already exist with this Name. ( Unique Name )");
return BadRequest("A rune already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<Rune>/5
[MapToApiVersion("2.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] RuneDTO runeDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - RUNE");
try
{
var rune = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(rune.First().Name);
var rune2 = await dataManager
.GetItemsByName(runeDTO.Name, 0, await dataManager.GetNbItems());
if (rune != null)
{
if (rune2.Count() == 0)
{
await dataManager.UpdateItem(rune.First(), runeDTO.ToModel());
return Ok();
}
_logger.LogInformation("rune already exist with this unique name.");
return BadRequest("rune already exist with this unique name.");
}
else
{
_logger.LogInformation("rune not found.");
return NotFound("rune not found.");
}
await dataManager.UpdateItem(rune.First(), runeDTO.ToModel());
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<RuneController>/5
[MapToApiVersion("2.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - RUNE");
try
{
var rune = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (rune.Count() != 0)
{
var runeDto = rune.First().ToDto();
await dataManager.DeleteItem(rune.First());
return Ok(runeDto);
}
else
{
_logger.LogInformation("No matching rune with this name");
return NotFound("No matching rune with this name");
}
}
catch (Exception error)
{
return BadRequest(error);
}
}
}
}

@ -0,0 +1,183 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace APILOL.Controllers.v2
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("2.0")]
public class RunePageController : ControllerBase
{
IRunePagesManager dataManager;
private readonly ILogger<RunePageController> _logger;
public RunePageController(IDataManager dataManager, ILogger<RunePageController> logger)
{
this.dataManager = dataManager.RunePagesMgr;
this._logger = logger;
}
// GET: api/<RunePageController>
[MapToApiVersion("2.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - RUNEPAGE");
try
{
var total = await dataManager.GetNbItems();
var runePages = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RunePageDTO> items = runePages.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No runePage found.");
return NotFound("No runePage found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// GET api/<RunePageController>/5
[MapToApiVersion("2.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - RUNEPAGE");
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var runepages = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<RunePageDTO> items = runepages.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No runePage found.");
return NotFound("No runePage found.");
}
return Ok(items);
}
return NotFound("No runePage matching with this name.");
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// POST api/<RunePageController>
[MapToApiVersion("2.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] RunePageDTO runePageDTO)
{
_logger.LogInformation("API call - [POST] - RUNEPAGE");
try
{
if (await dataManager.GetNbItemsByName(runePageDTO.Name) == 0)
{
await dataManager.AddItem(runePageDTO.ToModel());
return CreatedAtAction(nameof(Get), runePageDTO);
}
_logger.LogInformation("A runePage already exist with this Name. ( Unique Name )");
return BadRequest("A runePage already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<RunePage>/5
[MapToApiVersion("2.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] RunePageDTO runePageDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - RUNEPAGE");
try
{
var runePage = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(runePage.First().Name);
var runePage2 = await dataManager
.GetItemsByName(runePageDTO.Name, 0, await dataManager.GetNbItems());
if (runePage != null)
{
if (runePage2.Count() == 0)
{
await dataManager.UpdateItem(runePage.First(), runePageDTO.ToModel());
return Ok();
}
_logger.LogInformation("runePage already exist with this unique name.");
return BadRequest("runePage already exist with this unique name.");
}
else
{
_logger.LogInformation("runePage not found.");
return NotFound("runePage not found.");
}
await dataManager.UpdateItem(runePage.First(), runePageDTO.ToModel());
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<RunePageController>/5
[MapToApiVersion("2.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - RUNEPAGE");
try
{
var runePage = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (runePage.Count() != 0)
{
var runePageDto = runePage.First().ToDto();
await dataManager.DeleteItem(runePage.First());
return Ok(runePageDto);
}
else
{
_logger.LogInformation("No matching runePage with this name");
return NotFound("No matching runePage with this name");
}
}
catch (Exception error)
{
return BadRequest(error);
}
}
}
}
/*
var champion = new Champion("");
var dto = ChampionMapper.ToDto(champion);
*/

@ -0,0 +1,176 @@
using APILOL.Controllers.Request;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
namespace APILOL.Controllers.v2
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("2.0")]
public class SkinController : ControllerBase
{
ISkinsManager dataManager;
private readonly ILogger<SkinController> _logger;
public SkinController(IDataManager dataManager, ILogger<SkinController> logger)
{
this.dataManager = dataManager.SkinsMgr;
this._logger = logger;
}
// GET: api/<SkinController>
[MapToApiVersion("2.0")]
[HttpGet]
public async Task<IActionResult> Get([FromQuery] PageRequest request)
{
_logger.LogInformation("API call - [GET] - SKIN");
try
{
var total = await dataManager.GetNbItems();
var skins = await dataManager.GetItems(request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<SkinDTO> items = skins.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No skin found.");
return NotFound("No skin found.");
}
return Ok(new { data = items, count = await dataManager.GetNbItems(), offset = request.Offset, limit = request.Limit });
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// GET api/<SkinController>/5
[MapToApiVersion("2.0")]
[HttpGet("{name}")]
public async Task<IActionResult> Get([FromQuery] PageRequest request, string name)
{
_logger.LogInformation("API call - [GET / NAME] - SKIN");
try
{
if (dataManager.GetNbItemsByName(name) != null)
{
var skins = await dataManager.GetItemsByName(name, request.Offset, request.Limit, request.OrderingPropertyName, request.IsDesc);
IEnumerable<SkinDTO> items = skins.Select(c => c.ToDto());
if (items.Count() == 0)
{
_logger.LogInformation("No Skin found.");
return NotFound("No Skin found.");
}
return Ok(items);
}
return NotFound("No Skin matching with this name.");
}
catch (Exception error)
{
return BadRequest(error.Message);
}
}
// POST api/<SkinController>
[MapToApiVersion("2.0")]
[HttpPost]
public async Task<IActionResult> Post([FromBody] SkinDTO skinDTO)
{
_logger.LogInformation("API call - [POST] - SKIN");
try
{
if (await dataManager.GetNbItemsByName(skinDTO.Name) == 0)
{
await dataManager.AddItem(skinDTO.ToModel());
return CreatedAtAction(nameof(Get), skinDTO);
}
_logger.LogInformation("A Skin already exist with this Name. ( Unique Name )");
return BadRequest("A Skin already exist with this Name. ( Unique Name )");
}
catch (Exception error)
{
_logger.LogInformation("Error in the request");
return BadRequest(error.Message);
}
}
// PUT api/<Skin>/5
[MapToApiVersion("2.0")]
[HttpPut("{name}")]
public async Task<IActionResult> PutAsync(string name, [FromBody] SkinDTO skinDTO)
{
_logger.LogInformation("API call - [PUT / NAME] - SKIN");
try
{
var skin = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
Console.WriteLine(skin.First().Name);
var skin2 = await dataManager
.GetItemsByName(skinDTO.Name, 0, await dataManager.GetNbItems());
if (skin != null)
{
if (skin2.Count() == 0)
{
await dataManager.UpdateItem(skin.First(), skinDTO.ToModel());
return Ok();
}
_logger.LogInformation("Skin already exist with this unique name.");
return BadRequest("Skin already exist with this unique name.");
}
else
{
_logger.LogInformation("Skin not found.");
return NotFound("Skin not found.");
}
await dataManager.UpdateItem(skin.First(), skinDTO.ToModel());
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<SkinController>/5
[MapToApiVersion("2.0")]
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
_logger.LogInformation("API call - [DELETE / NAME] - SKIN");
try
{
var skin = await (dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems()));
if (skin.Count() != 0)
{
var skinDto = skin.First().ToDto();
await dataManager.DeleteItem(skin.First());
return Ok(skinDto);
}
else
{
_logger.LogInformation("No matching skin with this name");
return NotFound("No matching skin with this name");
}
}
catch (Exception error)
{
return BadRequest(error);
}
}
}
}

@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Mvc;
namespace APILOL.Controllers.v2
{
[ApiController]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("2.0")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[MapToApiVersion("2.0")]
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

@ -0,0 +1,26 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["APILOL/APILOL.csproj", "APILOL/"]
COPY ["DTO/DTO.csproj", "DTO/"]
COPY ["Model/Model.csproj", "Model/"]
COPY ["Shared/Shared.csproj", "Shared/"]
COPY ["StubLib/StubLib.csproj", "StubLib/"]
RUN dotnet restore "APILOL/APILOL.csproj"
COPY . .
WORKDIR "/src/APILOL"
RUN dotnet build "APILOL.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "APILOL.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "APILOL.dll"]

@ -1,4 +1,6 @@
using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model;
namespace APILOL.Mapper
@ -10,7 +12,44 @@ namespace APILOL.Mapper
return new ChampionDTO()
{
Name = champion.Name,
Bio = champion.Bio,
Class = champion.Class,
Icon = champion.Icon,
Image = champion.Image,
Skills = champion.Skills.Select(skill => skill.ToDto()),
};
}
public static Champion ToModel(this ChampionDTO champion)
{
return new Champion(champion.Name, champion.Class, champion.Icon, champion.Image.ToString(), champion.Bio);
}
public static Champion ToModel(this ChampionEntity entity)
{
var champion = new Champion(entity.Name, entity.Class, entity.Icon, "", entity.Bio);
if (entity.Skills != null) foreach (var s in entity.Skills) { champion.AddSkill(s.ToModel()); }
if (entity.Characteristics != null) foreach (var c in entity.Characteristics) { champion.AddCharacteristics(c.ToModel()); }
return champion;
}
public static ChampionEntity ToEntity(this Champion item, SQLiteContext context)
{
ChampionEntity? championEntity = context.Champion.Find(item.Name);
if (championEntity == null)
{
championEntity = new()
{
Name = item.Name,
Bio = item.Bio,
Icon = item.Icon,
Class = item.Class,
Image = new() { Base64 = item.Image.Base64 },
};
championEntity.Skills = item.Skills.Select(x => x.ToEntity(championEntity, context)).ToList();
championEntity.Characteristics = item.Characteristics.Select(x => x.ToEntity(championEntity, context)).ToList();
}
return championEntity;
}
}
}
}

@ -0,0 +1,26 @@
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
namespace APILOL.Mapper
{
public static class CharacteristicsMapper
{
public static CharacteristicEntity ToEntity(this KeyValuePair<string, int> item, ChampionEntity champion, SQLiteContext context)
{
var characteristicEntity = context.Characteristic.Find(item.Key, champion.Name);
if (characteristicEntity == null)
{
return new()
{
Name = item.Key,
Value = item.Value,
};
}
return characteristicEntity;
}
public static Tuple<string, int> ToModel(this CharacteristicEntity entity)
=> new(entity.Name, entity.Value);
}
}

@ -0,0 +1,46 @@
using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model;
namespace APILOL.Mapper
{
public static class RuneMapper
{
public static RuneDTO ToDto(this Rune rune)
{
return new RuneDTO()
{
Name = rune.Name,
Description = rune.Description,
Image = rune.Image.Base64,
Family = rune.Family,
};
}
public static Rune ToModel(this RuneDTO rune)
{
return new Rune(rune.Name, rune.Family, rune.Image, rune.Image, rune.Description);
}
public static Rune ToModel(this RuneEntity entity)
{
return new Rune(entity.Name, entity.Family, "", entity.Image.Base64, entity.Description);
}
public static RuneEntity ToEntity(this Rune item, SQLiteContext context)
{
RuneEntity? runeEntity = context.Rune.Find(item.Name);
if (runeEntity == null)
{
return new()
{
Name = item.Name,
Description = item.Description,
Family = item.Family
};
}
return runeEntity;
}
}
}

@ -0,0 +1,56 @@
using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model;
namespace APILOL.Mapper
{
public static class RunePageMapper
{
public static RunePageDTO ToDto(this RunePage runePage)
{
return new RunePageDTO()
{
Name = runePage.Name,
Runes = runePage.Runes
};
}
public static RunePage ToModel(this RunePageDTO runePage)
{
return new RunePage(runePage.Name);
}
public static RunePage ToModel(this RunePageEntity entity, SQLiteContext context)
{
RunePage runePage = new(entity.Name);
if (entity.Runes != null)
{
foreach (var r in entity.Runes)
{
var rune = context.Rune.Find(r.Name);
//if (rune != null) runePage[r.category] = rune.ToModel();
};
}
return runePage;
}
public static RunePageEntity ToEntity(this RunePage item, SQLiteContext context)
{
RunePageEntity? runePageEntity = context.RunePage.Find(item.Name);
if (runePageEntity == null)
{
runePageEntity = new()
{
Name = item.Name,
};
runePageEntity.Runes = new List<RuneEntity>();
foreach (var r in item.Runes)
{
runePageEntity.Runes.Add(r.Value.ToEntity(context));
}
}
return runePageEntity;
}
}
}

@ -0,0 +1,46 @@
using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model;
namespace APILOL.Mapper
{
public static class SkillMapper
{
public static SkillEntity ToEntity(this Skill item, ChampionEntity champion, SQLiteContext context)
{
var skillEntity = context.Skill.Find(item.Name);
if (skillEntity == null)
{
return new()
{
Name = item.Name,
Description = item.Description,
Type = item.Type,
Champions = new List<ChampionEntity>() { champion }
};
}
skillEntity!.Champions?.Add(champion);
return skillEntity;
}
public static Skill ToModel(this SkillEntity entity)
=> new(entity.Name, entity.Type, entity.Description);
public static SkillDTO ToDto(this Skill skill)
{
return new SkillDTO()
{
Type = skill.Type,
Name = skill.Name,
Description = skill.Description
};
}
public static Skill ToModel(this SkillDTO skill)
{
return new Skill(skill.Name, skill.Type, skill.Description);
}
}
}

@ -0,0 +1,46 @@
using DTO;
using EntityFrameworkLOL.DBContexts;
using EntityFrameworkLOL.Entities;
using Model;
namespace APILOL.Mapper
{
public static class SkinMapper
{
public static SkinDTO ToDto(this Skin skin)
{
return new SkinDTO()
{
Name = skin.Name,
Description = skin.Description,
Icon = skin.Icon,
Price = skin.Price,
Champion = skin.Champion.ToDto(),
Image = skin.Image.Base64,
};
}
public static Skin ToModel(this SkinDTO skin)
{
return new Skin(skin.Name, skin.Champion.ToModel(),skin.Price, skin.Image, skin.Icon, skin.Description);
}
public static Skin ToModel(this SkinEntity entity)
{
return new Skin(entity.Name, entity.ChampionSkin.ToModel(), entity.Price, entity.Icon, entity.Description);
}
public static SkinEntity ToEntity(this Skin item, SQLiteContext? context = null)
{
return new()
{
Name = item.Name,
ChampionSkin = context?.Champion.Find(item.Champion.Name) ?? item.Champion.ToEntity(context),
Description = item.Description,
Icon = item.Icon,
Image = null,
Price = item.Price
};
}
}
}

@ -1,28 +1,61 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;
using Model;
using StubLib;
using Swashbuckle.Swagger;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddSingleton<IDataManager, StubData>();
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddApiVersioning(opt =>
{
opt.DefaultApiVersion = new ApiVersion(1, 0);
opt.ApiVersionReader = new UrlSegmentApiVersionReader();
});
// Add ApiExplorer to discover versions
builder.Services.AddVersionedApiExplorer(setup =>
{
setup.GroupNameFormat = "'v'VVV";
setup.SubstituteApiVersionInUrl = true;
});
var app = builder.Build();
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseSwaggerUI(options =>
{
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
{
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
description.GroupName.ToUpperInvariant());
}
});
}
app.UseStaticFiles();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
app.Run();

@ -1,23 +1,14 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4308",
"sslPort": 44305
}
},
{
"profiles": {
"APILOL": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7015;http://localhost:5015",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7015;http://localhost:5015"
},
"IIS Express": {
"commandName": "IISExpress",
@ -26,6 +17,22 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4308",
"sslPort": 44305
}
}
}
}

@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace APILOL
{
public class SwaggerDefaultValues : IOperationFilter
{
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
var apiDescription = context.ApiDescription;
operation.Deprecated |= apiDescription.IsDeprecated();
if (operation.Parameters == null)
{
return;
}
foreach (var parameter in operation.Parameters)
{
var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name);
if (parameter.Description is null)
{
parameter.Description = description.ModelMetadata?.Description;
}
if (parameter.Schema.Default is null && description.DefaultValue is not null)
{
parameter.Schema.Default = new OpenApiString(description.DefaultValue.ToString());
}
parameter.Required |= description.IsRequired;
}
}
}
}

@ -1,7 +1,22 @@
namespace DTO
using Model;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
namespace DTO
{
public class ChampionDTO
{
public string Name { get; set; }
public string Bio { get; set; }
public ChampionClass Class { get; set; }
public string Icon { get; set; }
public LargeImage Image { get; set; }
public IEnumerable<SkillDTO> Skills { get; set; }
}
}

@ -14,6 +14,12 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
namespace DTO
{
public class RuneDTO
{
public string Name { get; set; }
public string Description { get; set; }
public string Image { get; set; }
public RuneFamily Family { get; set; }
}
}

@ -0,0 +1,12 @@
using Model;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace DTO
{
public class RunePageDTO
{
public string Name { get; set; }
public ReadOnlyDictionary<RunePage.Category, Rune> Runes { get; set; }
}
}

@ -0,0 +1,20 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{
public class SkillDTO
{
public SkillType Type { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{
public class SkinDTO
{
public string Name { get; set; }
public string Description { get; set; }
public string Icon { get; set; }
public float Price { get; set; }
public ChampionDTO Champion { get; set; }
public string Image { get; set; }
}
}

@ -1,13 +0,0 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class ChampionContext : DbContext
{
public DbSet<ChampionEntity> Champion { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -1,13 +0,0 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class RuneContext : DbContext
{
public DbSet<RuneEntity> Rune { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -1,15 +1,131 @@
using EntityFrameworkLOL.Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Model;
namespace EntityFrameworkLOL.DBContexts
{
class SQLiteContext : DbContext
public class SQLiteContext : DbContext
{
/*public DbSet<ChampionEntity> Champion { get; set; }
public DbSet<SkinEntity> Skin { get; set; }*/
public DbSet<ImageEntity> Image { get; set; }
public DbSet<SkillEntity> Skill { get; set; }
public DbSet<SkinEntity> Skin { get; set; }
public DbSet<RuneEntity> Rune { get; set; }
public DbSet<RunePageEntity> RunePage { get; set; }
public DbSet<CharacteristicEntity> Characteristic { get; set; }
public DbSet<ChampionEntity> Champion { get; set; }
public SQLiteContext() { }
public SQLiteContext(DbContextOptions<SQLiteContext> options)
: base(options)
{ }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
{
//var connection = new SqliteConnection("DataSource=:memory:");
var connection = new SqliteConnection("Data Source=DBLOL.db");
connection.Open();
options.UseSqlite(connection);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ImageEntity>().Property(i => i.Base64).ValueGeneratedOnAdd();
modelBuilder.Entity<CharacteristicEntity>().HasKey(c => new { c.Name });
modelBuilder.Entity<RunePageEntity>().Property(rp => rp.Name).ValueGeneratedOnAdd();
modelBuilder.Entity<RunePageEntity>()
.HasMany(rp => rp.Runes);
modelBuilder.Entity<ChampionEntity>()
.HasMany(c => c.RunePages)
.WithMany(rp => rp.Champions);
modelBuilder.Entity<ImageEntity>().HasData(new List<ImageEntity>()
{
new()
{
Base64 = "default"
}
});
modelBuilder.Entity<ChampionEntity>().HasData(new List<ChampionEntity>() {
new()
{
Name = "WinKer",
Bio = "Best front-end designer",
Class = ChampionClass.Mage,
Icon = "",
},
new()
{
Name = "Jonquille",
Bio = "Daffodil",
Class = ChampionClass.Support,
Icon = "",
}
});
modelBuilder.Entity<CharacteristicEntity>().HasData(new List<CharacteristicEntity>() {
new()
{
Name = "Front-end",
Value = 100,
},
new()
{
Name = "Back-end",
Value = 100,
}
});
modelBuilder.Entity<SkinEntity>().HasData(new List<SkinEntity>() {
new SkinEntity
{
Name = "Darker WinKer",
Description = "Be invisible in the darkness but never alone",
Icon = "default",
Price=9.99F
},
new SkinEntity
{
Name = "Summer Daffodil",
Description = "A jewel of Summer for all year long",
Icon = "default",
Price=9.99F
},
});
modelBuilder.Entity<SkillEntity>().HasData(new List<SkillEntity>() {
new()
{
Name = "Beautiful layout",
Description = "Bowl'In",
Type = SkillType.Ultimate
},
new()
{
Name = "DB Support",
Description = "DB",
Type = SkillType.Basic
}
});
modelBuilder.Entity<RunePageEntity>().HasData(new List<RunePageEntity>()
{
new()
{
Name="FirstRunepage"
}
});
modelBuilder.Entity<RuneEntity>().HasData(new List<RuneEntity>() {
new()
{
Name = "Mastering of Blue",
Description = "Blue shades",
Family = RuneFamily.Domination
},
new()
{
Name = "Empty Shards",
Description = "Remove runes",
Family = RuneFamily.Precision
}
});
}
}
}

@ -1,13 +0,0 @@
using EntityFrameworkLOL.Entities;
using Microsoft.EntityFrameworkCore;
namespace EntityFrameworkLOL.DBContexts
{
class SkinContext : DbContext
{
public DbSet<SkinEntity> Skin { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source=DBLOL.db");
}
}

@ -6,16 +6,35 @@ using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
using EntityFrameworkLOL.Entities;
namespace EntityFrameworkLOL.Entities
{
class ChampionEntity
public class ChampionEntity
{
[Key]
public string Name { get; set; }
[Required]
public string Bio { get; set; }
public string Icon { get; set; }
public string? Icon { get; set; }
[Required]
public ChampionClass Class { get; set; }
public ImageEntity? Image { get; set; }
public virtual ICollection<SkillEntity> Skills { get; set; }
public virtual ICollection<CharacteristicEntity> Characteristics { get; set; }
public virtual ICollection<RunePageEntity> RunePages { get; set; }
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EntityFrameworkLOL.Entities;
namespace EntityFrameworkLOL.Entities
{
public class CharacteristicEntity
{
[Key]
public string Name { get; set; }
[Required]
public int Value { get; set; }
public ChampionEntity Champion { get; set; }
//public virtual ICollection<ChampionEntity> Champions { get; set; }
}
}

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
namespace EntityFrameworkLOL.Entities
{
public class ImageEntity
{
[Key]
[ForeignKey("ChampionEntity")]
public string Base64 { get; set; }
}
}

@ -5,14 +5,22 @@ using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using Model;
namespace EntityFrameworkLOL.Entities
{
class RuneEntity
public class RuneEntity
{
[Key]
public string Name { get; set; }
public string Description { get; set; }
public ImageEntity Image { get; set; }
[Required]
public RuneFamily Family { get; set; }
public virtual ICollection<RunePageEntity> RunePages { get; set; }
}
}

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Reflection.PortableExecutable;
using System.Security.Claims;
namespace EntityFrameworkLOL.Entities
{
public class RunePageEntity
{
[Key]
public string Name { get; set; }
public virtual ICollection<RuneEntity> Runes { get; set; }
public virtual ICollection<ChampionEntity> Champions { get; set; }
}
}

@ -0,0 +1,19 @@
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Model.RunePage;
namespace EntityFrameworkLOL.Entities
{
public class RunePageRuneEntity
{
public Category Category { get; set; }
public RuneEntity Rune { get; set; }
public RunePageEntity RunePage { get; set; }
}
}

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Model;
namespace EntityFrameworkLOL.Entities
{
public class SkillEntity
{
[Key]
public string Name { get; set; }
public string Description { get; set; }
[Required]
public SkillType Type { get; set; }
public virtual ICollection<ChampionEntity> Champions { get; set; }
}
}

@ -8,15 +8,19 @@ using System.ComponentModel.DataAnnotations;
namespace EntityFrameworkLOL.Entities
{
class SkinEntity
public class SkinEntity
{
[Key]
public string Name { get; set; }
public string Description { get; set; }
/*public string Icon { get; set; }
public string? Icon { get; set; }
public float Price { get; set; }*/
public float Price { get; set; }
public ImageEntity Image { get; set; }
public ChampionEntity ChampionSkin { get; set; }
}
}

@ -19,10 +19,16 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -1,38 +0,0 @@
// <auto-generated />
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230202105714_MigrationWallah2")]
partial class MigrationWallah2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Rune");
});
#pragma warning restore 612, 618
}
}
}

@ -1,33 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Rune",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rune", x => x.Name);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Rune");
}
}
}

@ -0,0 +1,374 @@
// <auto-generated />
using EntityFrameworkLOL.DBContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFrameworkLOL.Migrations
{
[DbContext(typeof(SQLiteContext))]
[Migration("20230315161305_MigrationWallah6")]
partial class MigrationWallah6
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "RunePagesName");
b.HasIndex("RunePagesName");
b.ToTable("ChampionEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("ChampionEntitySkillEntity");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Champion");
b.HasData(
new
{
Name = "WinKer",
Bio = "Best front-end designer",
Class = 3,
Icon = ""
},
new
{
Name = "Jonquille",
Bio = "Daffodil",
Class = 5,
Icon = ""
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionName")
.HasColumnType("TEXT");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.HasIndex("ChampionName");
b.ToTable("Characteristic");
b.HasData(
new
{
Name = "Front-end",
Value = 100
},
new
{
Name = "Back-end",
Value = 100
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b =>
{
b.Property<string>("Base64")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Base64");
b.ToTable("Image");
b.HasData(
new
{
Base64 = "default"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Family")
.HasColumnType("INTEGER");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Rune");
b.HasData(
new
{
Name = "Mastering of Blue",
Description = "Blue shades",
Family = 2
},
new
{
Name = "Empty Shards",
Description = "Remove runes",
Family = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("RunePage");
b.HasData(
new
{
Name = "FirstRunepage"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
b.HasData(
new
{
Name = "Beautiful layout",
Description = "Bowl'In",
Type = 3
},
new
{
Name = "DB Support",
Description = "DB",
Type = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionSkinName")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionSkinName");
b.HasIndex("ImageBase64");
b.ToTable("Skin");
b.HasData(
new
{
Name = "Darker WinKer",
Description = "Be invisible in the darkness but never alone",
Icon = "default",
Price = 9.99f
},
new
{
Name = "Summer Daffodil",
Description = "A jewel of Summer for all year long",
Icon = "default",
Price = 9.99f
});
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.Property<string>("RunesName")
.HasColumnType("TEXT");
b.HasKey("RunePagesName", "RunesName");
b.HasIndex("RunesName");
b.ToTable("RuneEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.SkillEntity", null)
.WithMany()
.HasForeignKey("SkillsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "Champion")
.WithMany()
.HasForeignKey("ChampionName");
b.Navigation("Champion");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin")
.WithMany()
.HasForeignKey("ChampionSkinName");
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("ChampionSkin");
b.Navigation("Image");
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RuneEntity", null)
.WithMany()
.HasForeignKey("RunesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,335 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace EntityFrameworkLOL.Migrations
{
/// <inheritdoc />
public partial class MigrationWallah6 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Image",
columns: table => new
{
Base64 = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Image", x => x.Base64);
});
migrationBuilder.CreateTable(
name: "RunePage",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RunePage", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Skill",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Skill", x => x.Name);
});
migrationBuilder.CreateTable(
name: "Champion",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Bio = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: true),
Class = table.Column<int>(type: "INTEGER", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Champion", x => x.Name);
table.ForeignKey(
name: "FK_Champion_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateTable(
name: "Rune",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true),
Family = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rune", x => x.Name);
table.ForeignKey(
name: "FK_Rune_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateTable(
name: "ChampionEntityRunePageEntity",
columns: table => new
{
ChampionsName = table.Column<string>(type: "TEXT", nullable: false),
RunePagesName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionsName, x.RunePagesName });
table.ForeignKey(
name: "FK_ChampionEntityRunePageEntity_Champion_ChampionsName",
column: x => x.ChampionsName,
principalTable: "Champion",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChampionEntityRunePageEntity_RunePage_RunePagesName",
column: x => x.RunePagesName,
principalTable: "RunePage",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ChampionEntitySkillEntity",
columns: table => new
{
ChampionsName = table.Column<string>(type: "TEXT", nullable: false),
SkillsName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChampionEntitySkillEntity", x => new { x.ChampionsName, x.SkillsName });
table.ForeignKey(
name: "FK_ChampionEntitySkillEntity_Champion_ChampionsName",
column: x => x.ChampionsName,
principalTable: "Champion",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChampionEntitySkillEntity_Skill_SkillsName",
column: x => x.SkillsName,
principalTable: "Skill",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Characteristic",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Value = table.Column<int>(type: "INTEGER", nullable: false),
ChampionName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Characteristic", x => x.Name);
table.ForeignKey(
name: "FK_Characteristic_Champion_ChampionName",
column: x => x.ChampionName,
principalTable: "Champion",
principalColumn: "Name");
});
migrationBuilder.CreateTable(
name: "Skin",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: true),
Price = table.Column<float>(type: "REAL", nullable: false),
ImageBase64 = table.Column<string>(type: "TEXT", nullable: true),
ChampionSkinName = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Skin", x => x.Name);
table.ForeignKey(
name: "FK_Skin_Champion_ChampionSkinName",
column: x => x.ChampionSkinName,
principalTable: "Champion",
principalColumn: "Name");
table.ForeignKey(
name: "FK_Skin_Image_ImageBase64",
column: x => x.ImageBase64,
principalTable: "Image",
principalColumn: "Base64");
});
migrationBuilder.CreateTable(
name: "RuneEntityRunePageEntity",
columns: table => new
{
RunePagesName = table.Column<string>(type: "TEXT", nullable: false),
RunesName = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RuneEntityRunePageEntity", x => new { x.RunePagesName, x.RunesName });
table.ForeignKey(
name: "FK_RuneEntityRunePageEntity_RunePage_RunePagesName",
column: x => x.RunePagesName,
principalTable: "RunePage",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RuneEntityRunePageEntity_Rune_RunesName",
column: x => x.RunesName,
principalTable: "Rune",
principalColumn: "Name",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Champion",
columns: new[] { "Name", "Bio", "Class", "Icon", "ImageBase64" },
values: new object[,]
{
{ "Jonquille", "Daffodil", 5, "", null },
{ "WinKer", "Best front-end designer", 3, "", null }
});
migrationBuilder.InsertData(
table: "Characteristic",
columns: new[] { "Name", "ChampionName", "Value" },
values: new object[,]
{
{ "Back-end", null, 100 },
{ "Front-end", null, 100 }
});
migrationBuilder.InsertData(
table: "Image",
column: "Base64",
value: "default");
migrationBuilder.InsertData(
table: "Rune",
columns: new[] { "Name", "Description", "Family", "ImageBase64" },
values: new object[,]
{
{ "Empty Shards", "Remove runes", 1, null },
{ "Mastering of Blue", "Blue shades", 2, null }
});
migrationBuilder.InsertData(
table: "RunePage",
column: "Name",
value: "FirstRunepage");
migrationBuilder.InsertData(
table: "Skill",
columns: new[] { "Name", "Description", "Type" },
values: new object[,]
{
{ "Beautiful layout", "Bowl'In", 3 },
{ "DB Support", "DB", 1 }
});
migrationBuilder.InsertData(
table: "Skin",
columns: new[] { "Name", "ChampionSkinName", "Description", "Icon", "ImageBase64", "Price" },
values: new object[,]
{
{ "Darker WinKer", null, "Be invisible in the darkness but never alone", "default", null, 9.99f },
{ "Summer Daffodil", null, "A jewel of Summer for all year long", "default", null, 9.99f }
});
migrationBuilder.CreateIndex(
name: "IX_Champion_ImageBase64",
table: "Champion",
column: "ImageBase64");
migrationBuilder.CreateIndex(
name: "IX_ChampionEntityRunePageEntity_RunePagesName",
table: "ChampionEntityRunePageEntity",
column: "RunePagesName");
migrationBuilder.CreateIndex(
name: "IX_ChampionEntitySkillEntity_SkillsName",
table: "ChampionEntitySkillEntity",
column: "SkillsName");
migrationBuilder.CreateIndex(
name: "IX_Characteristic_ChampionName",
table: "Characteristic",
column: "ChampionName");
migrationBuilder.CreateIndex(
name: "IX_Rune_ImageBase64",
table: "Rune",
column: "ImageBase64");
migrationBuilder.CreateIndex(
name: "IX_RuneEntityRunePageEntity_RunesName",
table: "RuneEntityRunePageEntity",
column: "RunesName");
migrationBuilder.CreateIndex(
name: "IX_Skin_ChampionSkinName",
table: "Skin",
column: "ChampionSkinName");
migrationBuilder.CreateIndex(
name: "IX_Skin_ImageBase64",
table: "Skin",
column: "ImageBase64");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChampionEntityRunePageEntity");
migrationBuilder.DropTable(
name: "ChampionEntitySkillEntity");
migrationBuilder.DropTable(
name: "Characteristic");
migrationBuilder.DropTable(
name: "RuneEntityRunePageEntity");
migrationBuilder.DropTable(
name: "Skin");
migrationBuilder.DropTable(
name: "Skill");
migrationBuilder.DropTable(
name: "RunePage");
migrationBuilder.DropTable(
name: "Rune");
migrationBuilder.DropTable(
name: "Champion");
migrationBuilder.DropTable(
name: "Image");
}
}
}

@ -16,6 +16,124 @@ namespace EntityFrameworkLOL.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "RunePagesName");
b.HasIndex("RunePagesName");
b.ToTable("ChampionEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.Property<string>("ChampionsName")
.HasColumnType("TEXT");
b.Property<string>("SkillsName")
.HasColumnType("TEXT");
b.HasKey("ChampionsName", "SkillsName");
b.HasIndex("SkillsName");
b.ToTable("ChampionEntitySkillEntity");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Class")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Champion");
b.HasData(
new
{
Name = "WinKer",
Bio = "Best front-end designer",
Class = 3,
Icon = ""
},
new
{
Name = "Jonquille",
Bio = "Daffodil",
Class = 5,
Icon = ""
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionName")
.HasColumnType("TEXT");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.HasIndex("ChampionName");
b.ToTable("Characteristic");
b.HasData(
new
{
Name = "Front-end",
Value = 100
},
new
{
Name = "Back-end",
Value = 100
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b =>
{
b.Property<string>("Base64")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Base64");
b.ToTable("Image");
b.HasData(
new
{
Base64 = "default"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.Property<string>("Name")
@ -25,9 +143,227 @@ namespace EntityFrameworkLOL.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Family")
.HasColumnType("INTEGER");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.HasKey("Name");
b.HasIndex("ImageBase64");
b.ToTable("Rune");
b.HasData(
new
{
Name = "Mastering of Blue",
Description = "Blue shades",
Family = 2
},
new
{
Name = "Empty Shards",
Description = "Remove runes",
Family = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("RunePage");
b.HasData(
new
{
Name = "FirstRunepage"
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.ToTable("Skill");
b.HasData(
new
{
Name = "Beautiful layout",
Description = "Bowl'In",
Type = 3
},
new
{
Name = "DB Support",
Description = "DB",
Type = 1
});
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("ChampionSkinName")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Icon")
.HasColumnType("TEXT");
b.Property<string>("ImageBase64")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionSkinName");
b.HasIndex("ImageBase64");
b.ToTable("Skin");
b.HasData(
new
{
Name = "Darker WinKer",
Description = "Be invisible in the darkness but never alone",
Icon = "default",
Price = 9.99f
},
new
{
Name = "Summer Daffodil",
Description = "A jewel of Summer for all year long",
Icon = "default",
Price = 9.99f
});
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.Property<string>("RunePagesName")
.HasColumnType("TEXT");
b.Property<string>("RunesName")
.HasColumnType("TEXT");
b.HasKey("RunePagesName", "RunesName");
b.HasIndex("RunesName");
b.ToTable("RuneEntityRunePageEntity");
});
modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ChampionEntitySkillEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", null)
.WithMany()
.HasForeignKey("ChampionsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.SkillEntity", null)
.WithMany()
.HasForeignKey("SkillsName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.CharacteristicEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "Champion")
.WithMany()
.HasForeignKey("ChampionName");
b.Navigation("Champion");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("Image");
});
modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin")
.WithMany()
.HasForeignKey("ChampionSkinName");
b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image")
.WithMany()
.HasForeignKey("ImageBase64");
b.Navigation("ChampionSkin");
b.Navigation("Image");
});
modelBuilder.Entity("RuneEntityRunePageEntity", b =>
{
b.HasOne("EntityFrameworkLOL.Entities.RunePageEntity", null)
.WithMany()
.HasForeignKey("RunePagesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("EntityFrameworkLOL.Entities.RuneEntity", null)
.WithMany()
.HasForeignKey("RunesName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}

@ -8,90 +8,5 @@ class Program
{
static void Main(string[] args)
{
ChampionEntity akali = new ChampionEntity { Name = "Akali" };
ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox" };
ChampionEntity ahri = new ChampionEntity { Name = "Ahri" };
ChampionEntity bard = new ChampionEntity { Name = "Bard" };
ChampionEntity alistar = new ChampionEntity { Name = "Alistar" };
ChampionEntity akshan = new ChampionEntity { Name = "Akshan" };
using (var context = new ChampionContext())
{
// Crée des champions et les insère dans la base
Console.WriteLine("Creates and inserts new Champions");
context.Add(akali);
context.Add(aatrox);
context.Add(ahri);
context.Add(bard);
context.Add(alistar);
context.Add(akshan);
context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":");
var aChampion = context.Champion
.Where(c => c.Name.StartsWith("A"))
.First();
Console.WriteLine($"{aChampion.Name} (with bio : {aChampion.Bio}");
}
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" };
RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" };
RuneEntity alacrity = new RuneEntity { Name = "Legend : Alacrity", Description = "" };
RuneEntity tenacity = new RuneEntity { Name = "Legend : Tenacity", Description = "" };
RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" };
RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" };
using (var context = new RuneContext())
{
// Crée des Runes et les insère dans la base
Console.WriteLine("Creates and inserts new Runes");
context.Add(conqueror);
context.Add(thriumph);
context.Add(alacrity);
context.Add(tenacity);
context.Add(laststand);
context.Add(laststand2);
context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Runes of the database whose name starts with an \"L\":");
var lRune = context.Rune
.Where(r => r.Name.StartsWith("L"))
.First();
Console.WriteLine($"{lRune.Name} (with Description : {lRune.Description}");
}
SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" };
SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" };
SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" };
SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" };
SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" };
SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" };
using (var context = new SkinContext())
{
// Crée des Skins et les insère dans la base
Console.WriteLine("Creates and inserts new Skins");
context.Add(stinger);
context.Add(infernal);
context.Add(allStar);
context.Add(justicar);
context.Add(mecha);
context.Add(seaHunter);
context.SaveChanges();
Console.WriteLine("Creates and executes a query retrieving the first Skins of the database whose name starts with an \"I\":");
var iSkin = context.Skin
.Where(s => s.Name.StartsWith("I"))
.First();
Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}");
Console.WriteLine("Updates the name of the Infernal Skin");
iSkin.Name = "Infernal of Hell (Wallah)";
context.SaveChanges();
Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}");
Console.WriteLine("Deletes one item from the database");
var droid = context.Skin
.SingleOrDefault(s => s.Name.Equals("Infernal"));
context.Remove(droid);
context.SaveChanges();
}
}
}

@ -19,7 +19,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APILOL", "APILOL\APILOL.csp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{1434DEF6-0575-4C3D-BF14-AF29A444BC74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkLOL", "EntityFrameworkLOL\EntityFrameworkLOL.csproj", "{61D807B0-FA1A-439D-9810-9F31A0C47034}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFrameworkLOL", "EntityFrameworkLOL\EntityFrameworkLOL.csproj", "{61D807B0-FA1A-439D-9810-9F31A0C47034}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{D24FBC48-F9C3-45CA-8D51-A851559C307F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagersEF", "ManagersEF\ManagersEF.csproj", "{A8685E74-67E4-4382-AF91-38045AC0014B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestEF", "TestEF\TestEF.csproj", "{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -55,6 +61,18 @@ Global
{61D807B0-FA1A-439D-9810-9F31A0C47034}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61D807B0-FA1A-439D-9810-9F31A0C47034}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61D807B0-FA1A-439D-9810-9F31A0C47034}.Release|Any CPU.Build.0 = Release|Any CPU
{D24FBC48-F9C3-45CA-8D51-A851559C307F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D24FBC48-F9C3-45CA-8D51-A851559C307F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D24FBC48-F9C3-45CA-8D51-A851559C307F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D24FBC48-F9C3-45CA-8D51-A851559C307F}.Release|Any CPU.Build.0 = Release|Any CPU
{A8685E74-67E4-4382-AF91-38045AC0014B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8685E74-67E4-4382-AF91-38045AC0014B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8685E74-67E4-4382-AF91-38045AC0014B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8685E74-67E4-4382-AF91-38045AC0014B}.Release|Any CPU.Build.0 = Release|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81CEA57F-3CCB-4CF8-8315-2B5BC403E0FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -62,6 +80,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{D24FBC48-F9C3-45CA-8D51-A851559C307F} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}

@ -0,0 +1,147 @@
using Model;
using Shared;
using System.Data.SqlTypes;
using APILOL.Mapper;
using Microsoft.EntityFrameworkCore;
using System.Xml.Linq;
namespace ManagersEF
{
public partial class EFManager
{
public class ChampionsManager : IChampionsManager
{
private readonly EFManager parent;
public ChampionsManager(EFManager parent)
=> this.parent = parent;
public async Task<Champion?> AddItem(Champion? item)
{
await parent.DbContext.Champion.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item;
}
public async Task<bool> DeleteItem(Champion? item)
{
var toDelete = parent.DbContext.Champion.Find(item.Name);
if (toDelete != null)
{
parent.DbContext.Champion.Remove(toDelete);
parent.DbContext.SaveChanges();
return true;
}
return false;
}
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
Console.WriteLine("GET");
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering(
c => true,
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Champion.Include("Characteristics").GetItemsWithFilterAndOrdering(
c => c.Characteristics.Any(ch => ch.Name.Equals(charName)),
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering(
c => c.Class.Equals(championClass),
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering(
c => c.Name.Contains(substring),
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Champion.Include("runepages").GetItemsWithFilterAndOrdering(
c => c.RunePages.Any(rp => rp.Equals(runePage.ToEntity(parent.DbContext))),
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Champion.GetItemsWithFilterAndOrdering(
c => skill != null && c.Skills.Any(s => s.Name.Equals(skill.Name)),
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<IEnumerable<Champion?>> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Champion.Include("Skills").GetItemsWithFilterAndOrdering(
c => skill != null && c.Skills.Any(s => s.Name.Equals(skill)),
index, count,
orderingPropertyName, descending).Select(c => c.ToModel());
}
public async Task<int> GetNbItems()
{
return parent.DbContext.Champion.Count();
}
public async Task<int> GetNbItemsByCharacteristic(string charName)
{
return parent.DbContext.Champion.Where(c => c.Characteristics.Any(ch => ch.Name.Equals(charName))).Count();
}
public async Task<int> GetNbItemsByClass(ChampionClass championClass)
{
return parent.DbContext.Champion.Where(c => c.Class.Equals(championClass))
.Count();
}
public async Task<int> GetNbItemsByName(string substring)
{
return parent.DbContext.Champion.Where(c => c.Name.Contains(substring))
.Count();
}
public async Task<int> GetNbItemsByRunePage(RunePage? runePage)
{
return parent.DbContext.Champion.Where(c => c.RunePages.Any(rp => rp.Equals(runePage.ToEntity(parent.DbContext)))).Count();
}
public async Task<int> GetNbItemsBySkill(Skill? skill)
{
return parent.DbContext.Champion.Where(c => skill != null && c.Skills.Any(s => s.Name.Equals(skill.Name)))
.Count();
}
public async Task<int> GetNbItemsBySkill(string skill)
{
return parent.DbContext.Champion.Where(c => skill != null && c.Skills.Any(s => s.Name.Equals(skill)))
.Count();
}
public async Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem)
{
var toUpdate = parent.DbContext.Champion.Find(oldItem.Name);
toUpdate = newItem.ToEntity(parent.DbContext);
parent.DbContext.SaveChanges();
return newItem;
}
}
}
}

@ -0,0 +1,115 @@
using APILOL.Mapper;
using EntityFrameworkLOL.Entities;
using ManagersEF;
using Microsoft.EntityFrameworkCore;
using Model;
using System.Data.SqlTypes;
using System.Linq;
using System.Xml.Linq;
namespace ManagersEF
{
public partial class EFManager
{
public class RunePagesManager : IRunePagesManager
{
private readonly EFManager parent;
public RunePagesManager(EFManager parent)
=> this.parent = parent;
public async Task<RunePage?> AddItem(RunePage? item)
{
await parent.DbContext.RunePage.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item;
}
public async Task<bool> DeleteItem(RunePage? item)
{
var toDelete = parent.DbContext.RunePage.Find(item.Name);
if (toDelete != null)
{
parent.DbContext.RunePage.Remove(toDelete);
parent.DbContext.SaveChanges();
return true;
}
return false;
}
public async Task<IEnumerable<RunePage?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering(
rp => true,
index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
}
public async Task<IEnumerable<RunePage?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.RunePage.Include("champions").GetItemsWithFilterAndOrdering(
rp => rp.Champions.Any(c => c.Name.Equals(champion.Name)),
index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
}
public async Task<IEnumerable<RunePage?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.RunePage.GetItemsWithFilterAndOrdering(
rp => rp.Name.Contains(substring),
index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
}
public async Task<IEnumerable<RunePage?>> GetItemsByRune(Rune? rune, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.RunePage.Include("entries").GetItemsWithFilterAndOrdering(
rp => rp.entries.Any(r => r.RuneName.Equals(rune.Name)),
index, count,
orderingPropertyName, descending).Select(rp => rp.ToModel(parent.DbContext));
}
public async Task<int> GetNbItems()
{
return parent.DbContext.RunePage.Count();
}
public async Task<int> GetNbItemsByChampion(Champion? champion)
{
return parent.DbContext.RunePage.Where(rp => rp.champions.Any(c => c.Name.Equals(champion.Name))).Count();
}
public async Task<int> GetNbItemsByName(string substring)
{
return parent.DbContext.RunePage.Where(rp => rp.Name.Contains(substring)).Count();
}
public async Task<int> GetNbItemsByRune(Model.Rune? rune)
{
return parent.DbContext.RunePage.Where(rp => rp.entries.Any(r => r.RuneName.Equals(rune.Name))).Count();
}
public async Task<RunePage?> UpdateItem(RunePage? oldItem, RunePage? newItem)
{
var toUpdate = parent.DbContext.RunePage.Include("entries")
.Where(x => x.Name.Equals(newItem.Name)).First();
try
{
toUpdate.entries = newItem.Runes.Select(r => new RunePageRuneEntity()
{
category = r.Key,
rune = r.Value.ToEntity(parent.DbContext),
}).ToList();
parent.DbContext.SaveChanges();
}
catch (DbUpdateException) { }
return newItem;
}
}
}
}

@ -0,0 +1,85 @@
using APILOL.Mapper;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System.Xml.Linq;
namespace ManagersEF
{
public partial class EFManager
{
public class RunesManager : IRunesManager
{
private readonly EFManager parent;
public RunesManager(EFManager parent)
=> this.parent = parent;
public async Task<Rune?> AddItem(Rune? item)
{
await parent.DbContext.Rune.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item;
}
public async Task<bool> DeleteItem(Rune? item)
{
var toDelete = parent.DbContext.Rune.Find(item?.Name);
if (toDelete != null)
{
parent.DbContext.Rune.Remove(item?.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return true;
}
return false;
}
public async Task<IEnumerable<Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Rune.GetItemsWithFilterAndOrdering(
r => true,
index, count,
orderingPropertyName, descending).Select(r => r.ToModel());
}
public async Task<IEnumerable<Rune?>> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Rune.GetItemsWithFilterAndOrdering(
r => r.Family.Equals(family),
index, count,
orderingPropertyName, descending).Select(r => r.ToModel());
}
public async Task<IEnumerable<Rune?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Rune.GetItemsWithFilterAndOrdering(
r => r.Name.Contains(substring),
index, count,
orderingPropertyName, descending).Select(r => r.ToModel());
}
public async Task<int> GetNbItems()
{
return parent.DbContext.Rune.Count();
}
public async Task<int> GetNbItemsByFamily(RuneFamily family)
{
return parent.DbContext.Rune.Where(r => r.Family.Equals(family)).Count();
}
public async Task<int> GetNbItemsByName(string substring)
{
return parent.DbContext.Rune.Where(r => r.Name.Contains(substring)).Count();
}
public async Task<Rune?> UpdateItem(Rune? oldItem, Rune? newItem)
{
var toUpdate = parent.DbContext.Rune.Find(oldItem.Name);
toUpdate.Description = newItem.Description;
toUpdate.Family = newItem.Family;
parent.DbContext.SaveChanges();
return newItem;
}
}
}
}

@ -0,0 +1,90 @@
using APILOL.Mapper;
using Microsoft.EntityFrameworkCore;
using Model;
using System.Data.SqlTypes;
using System.Xml.Linq;
namespace ManagersEF
{
public partial class EFManager
{
public class SkinsManager : ISkinsManager
{
private readonly EFManager parent;
public SkinsManager(EFManager parent)
=> this.parent = parent;
public async Task<Skin?> AddItem(Skin? item)
{
await parent.DbContext.Skin.AddAsync(item.ToEntity(parent.DbContext));
parent.DbContext.SaveChanges();
return item;
}
public async Task<bool> DeleteItem(Skin? item)
{
var toDelete = parent.DbContext.Skin.Find(item.Name);
if (toDelete != null)
{
parent.DbContext.Skin.Remove(toDelete);
parent.DbContext.SaveChanges();
return true;
}
return false;
}
public async Task<IEnumerable<Skin?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Skin.Include("Champion").GetItemsWithFilterAndOrdering(
s => true,
index, count,
orderingPropertyName, descending).Select(s => s?.ToModel());
}
public async Task<IEnumerable<Skin?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Skin.Include("Champion").GetItemsWithFilterAndOrdering(
s => s.ChampionSkin.Name.Equals(champion?.Name),
index, count,
orderingPropertyName, descending).Select(s => s?.ToModel());
}
public async Task<IEnumerable<Skin?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
return parent.DbContext.Skin.Include("Champion").GetItemsWithFilterAndOrdering(
s => s.Name.Contains(substring),
index, count,
orderingPropertyName, descending).Select(s => s?.ToModel());
}
public async Task<int> GetNbItems()
{
return parent.DbContext.Skin.Count();
}
public async Task<int> GetNbItemsByChampion(Champion? champion)
{
if (champion != null)
{
return parent.DbContext.Skin.Where(s => s.ChampionSkin.Name.Equals(champion.Name))
.Count();
}
return 0;
}
public async Task<int> GetNbItemsByName(string substring)
{
return parent.DbContext.Skin.Where(s => s.Name.Contains(substring))
.Count();
}
public async Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem)
{
var toUpdate = parent.DbContext.Skin.Find(oldItem.Name);
toUpdate.ChampionSkin = parent.DbContext.Champion.Find(newItem.Champion.Name);
return newItem;
}
}
}
}

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Model;
using EntityFrameworkLOL.DBContexts;
namespace ManagersEF
{
public partial class EFManager : IDataManager
{
public EFManager(SQLiteContext dbContext)
{
DbContext = dbContext;
ChampionsMgr = new ChampionsManager(this);
SkinsMgr = new SkinsManager(this);
RunesMgr = new RunesManager(this);
RunePagesMgr = new RunePagesManager(this);
}
protected SQLiteContext DbContext { get; }
public IChampionsManager ChampionsMgr { get; }
public ISkinsManager SkinsMgr { get; }
public IRunesManager RunesMgr { get; }
public IRunePagesManager RunePagesMgr { get; }
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ManagersEF
{
static class Extensions
{
internal static IEnumerable<T?> GetItemsWithFilterAndOrdering<T>(this IEnumerable<T> collection,
Func<T, bool> filter, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
IEnumerable<T> temp = collection;
temp = temp.Where(item => filter(item));
if (orderingPropertyName != null)
{
var prop = typeof(T).GetProperty(orderingPropertyName!);
if (prop != null)
{
temp = descending ? temp.OrderByDescending(item => prop.GetValue(item))
: temp.OrderBy(item => prop.GetValue(item));
}
}
return temp.Skip(index * count).Take(count);
}
}
}

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\EntityFrameworkLOL\EntityFrameworkLOL.csproj" />
<ProjectReference Include="..\APILOL\APILOL.csproj" />
</ItemGroup>
</Project>

@ -20,6 +20,8 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />

@ -2,10 +2,11 @@
public interface IGenericDataManager<T>
{
Task<int> GetNbItems();
Task<IEnumerable<T>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false);
Task<IEnumerable<T>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false);
Task<int> GetNbItemsByName(string substring);
Task<IEnumerable<T>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false);
Task<T> UpdateItem(T oldItem, T newItem);
Task<T> UpdateItem(T oldItem, T newItem);
Task<T> AddItem(T item);
Task<bool> DeleteItem(T item);
}

@ -14,6 +14,8 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
</Project>

@ -60,6 +60,7 @@ namespace StubLib
collection.Add(newItem!);
return Task.FromResult<T?>(newItem);
}
}
}

@ -1,4 +1,6 @@
using System;
using System.Data.SqlTypes;
using System.Linq;
using Model;
namespace StubLib
@ -25,12 +27,18 @@ namespace StubLib
public Task<Champion?> AddItem(Champion? item)
=> parent.champions.AddItem(item);
public Task<bool> DeleteItem(Champion? item)
=> parent.champions.DeleteItem(item);
public Task<int> GetNbItems()
=> Task.FromResult(parent.champions.Count);
public Champion GetLast()
=> parent.champions.Last();
public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
=> parent.champions.GetItemsWithFilterAndOrdering(
c => true,
@ -84,7 +92,7 @@ namespace StubLib
.Select(tuple => tuple.Item1)
.Skip(index*count).Take(count));
private Func<Champion, string, bool> filterByName = (champ, substring) => champ.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase);
private Func<Champion, string, bool> filterByName = (champ, substring) => champ.Name.Equals(substring);
public Task<int> GetNbItemsByName(string substring)
=> parent.champions.GetNbItemsWithFilter(champ => filterByName(champ, substring));
@ -94,6 +102,7 @@ namespace StubLib
public Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem)
=> parent.champions.UpdateItem(oldItem, newItem);
}
}
}

@ -77,6 +77,7 @@ namespace StubLib
public Task<RunePage?> UpdateItem(RunePage? oldItem, RunePage? newItem)
=> parent.runePages.UpdateItem(oldItem, newItem);
}
}
}

@ -63,6 +63,7 @@ namespace StubLib
public Task<Rune?> UpdateItem(Rune? oldItem, Rune? newItem)
=> parent.runes.UpdateItem(oldItem, newItem);
}
}
}

@ -74,6 +74,7 @@ namespace StubLib
public Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem)
=> parent.skins.UpdateItem(oldItem, newItem);
}
}
}

@ -14,6 +14,8 @@
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>

@ -0,0 +1,189 @@
using EntityFrameworkLOL.Entities;
using EntityFrameworkLOL.DBContexts;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System.Xml.Linq;
using Xunit.Abstractions;
using Xunit;
using ManagersEF;
namespace TestEF
{
public class TestChampions
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
batman.AddSkill(new("Bat-signal", SkillType.Basic, "Envoie le signal"));
batman.AddCharacteristics(new[] {
Tuple.Create("Force", 150),
Tuple.Create("Agilité", 500)
});
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
endeavor.AddSkill(new("Final flames", SkillType.Ultimate, "Dernière flamme d'un héro"));
endeavor.AddCharacteristics(new[] {
Tuple.Create("Force", 200),
Tuple.Create("Défense", 300),
Tuple.Create("Alter", 800)
});
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
escanor.AddSkill(new("Croissance solaire", SkillType.Passive, "Le soleil rends plus fort !"));
escanor.AddCharacteristics(new[] {
Tuple.Create("Force", 500),
Tuple.Create("Défense", 500)
});
await manager.AddItem(batman);
await manager.AddItem(endeavor);
await manager.AddItem(escanor);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
var nbItems = await manager.GetNbItems();
Assert.Equal(3, nbItems);
var items = await manager.GetItemsByName("Batman", 0, nbItems);
Assert.Equal("Batman", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByName("E"));
items = await manager.GetItemsBySkill("Croissance solaire", 0, nbItems);
Assert.Equal("Escanor", items.First().Name);
items = await manager.GetItemsBySkill(new Skill("Final flames", SkillType.Ultimate, "Dernière flamme d'un héro"),
0, nbItems);
Assert.Equal("Endeavor", items.First().Name);
items = await manager.GetItemsByCharacteristic("Alter", 0, nbItems);
Assert.Equal("Endeavor", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByCharacteristic("Défense"));
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
await manager.AddItem(batman);
await manager.AddItem(endeavor);
await manager.AddItem(escanor);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
var items = await manager.GetItemsByName("E", 0, 3);
Assert.Equal(2, items.Count());
var escanor = context.Champion.Where(n => n.Name.Contains("Esc")).First();
escanor.Class = ChampionClass.Tank;
context.SaveChanges();
items = await manager.GetItemsByClass(ChampionClass.Tank, 0, 3);
Assert.Contains("Escanor", items.Select(x => x.Name));
Assert.Equal(2, await manager.GetNbItemsByClass(ChampionClass.Tank));
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
batman.AddSkill(new("Charge", SkillType.Basic, "Coup de base"));
batman.AddSkill(new("Double Saut", SkillType.Basic, ""));
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
endeavor.AddSkill(new("Charge", SkillType.Basic, "Coup de base"));
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
escanor.AddSkill(new("Charge", SkillType.Basic, "Coup de base"));
batman.AddSkill(new("Double Saut", SkillType.Basic, ""));
await manager.AddItem(batman);
await manager.AddItem(endeavor);
await manager.AddItem(escanor);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
var endeavor = (await manager.GetItemsByName("Endeavor", 0, 3)).First();
var itemsByName = await manager.DeleteItem(endeavor);
Assert.Equal(2, await manager.GetNbItems());
var items = await manager.GetItems(0, await manager.GetNbItems());
Assert.DoesNotContain("Endeavor", items.Select(x => x.Name));
Assert.Equal(1, await manager.GetNbItemsBySkill(new Skill("Double Saut", SkillType.Basic, "")));
Assert.Equal(2, await manager.GetNbItemsBySkill("Charge"));
}
}
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\EntityFrameworkLOL\EntityFrameworkLOL.csproj" />
<ProjectReference Include="..\APILOL\APILOL.csproj" />
<ProjectReference Include="..\ManagersEF\ManagersEF.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,277 @@
using ManagersEF;
using EntityFrameworkLOL.Entities;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Model.RunePage;
using System.Xml.Linq;
using Xunit;
using EntityFrameworkLOL.DBContexts;
namespace TestEF
{
public class TestRunePages
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var runeManager = new EFManager(context).RunesMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
Model.Rune rune4 = new("The moon", RuneFamily.Unknown);
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
RunePage runepage1 = new("Damages");
runepage1[Category.Major] = rune1;
runepage1[Category.Minor1] = rune2;
runepage1[Category.Minor2] = rune5;
RunePage runepage2 = new("Hawk");
runepage2[Category.Major] = rune6;
runepage2[Category.Minor1] = rune2;
RunePage runepage3 = new("Juggler");
runepage3[Category.Major] = rune5;
runepage3[Category.Minor1] = rune3;
runepage3[Category.Minor2] = rune2;
await runeManager.AddItem(rune1);
await runeManager.AddItem(rune2);
await runeManager.AddItem(rune3);
await runeManager.AddItem(rune4);
await runeManager.AddItem(rune5);
await runeManager.AddItem(rune6);
await manager.AddItem(runepage1);
await manager.AddItem(runepage2);
await manager.AddItem(runepage3);
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
Champion escanor = new("Escanor", ChampionClass.Fighter, "icon_3", "image_3", "1, 2, 3, Soleil");
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
await championManager.AddItem(escanor);
var runepage_entities = context.RunePage;
var champion_entities = context.Champion;
var damages = runepage_entities.Find("Damages");
var hawk = runepage_entities.Find("Hawk");
var juggler = runepage_entities.Find("Juggler");
champion_entities.Find("Batman")!.RunePages = new List<RunePageEntity>() { hawk, juggler };
champion_entities.Find("Endeavor")!.RunePages = new List<RunePageEntity>() { damages };
champion_entities.Find("Escanor")!.RunePages = new List<RunePageEntity>() { damages };
context.SaveChanges();
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Champion batman = new("Batman", ChampionClass.Assassin, "icon_1", "image_1", "L'ombre de la nuit");
Champion endeavor = new("Endeavor", ChampionClass.Tank, "icon_2", "image_2", "Feu brûlant énernel");
var nbItems = await manager.GetNbItems();
Assert.Equal(3, nbItems);
var items = await manager.GetItemsByName("Ha", 0, nbItems);
Assert.Equal("Hawk", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByName("a"));
Assert.Equal(1, await manager.GetNbItemsByRune(rune5));
items = await manager.GetItemsByRune(rune1, 0, nbItems);
Assert.Equal("Damages", items.First().Name);
Assert.Equal(2, await manager.GetNbItemsByChampion(batman));
Assert.Equal("Damages", (await manager.GetItemsByChampion(endeavor, 0, 3)).First()!.Name);
Assert.Equal(2, await championManager.GetNbItemsByRunePage(new("Damages")));
Assert.Equal("Batman", (await championManager.GetItemsByRunePage(new("Juggler"), 0, 3)).First()!.Name);
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var runeManager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
Model.Rune rune4 = new("The moon", RuneFamily.Unknown);
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
RunePage runepage1 = new("Damages");
runepage1[Category.Major] = rune1;
runepage1[Category.Minor1] = rune2;
runepage1[Category.Minor2] = rune5;
RunePage runepage2 = new("Hawk");
runepage2[Category.Major] = rune6;
runepage2[Category.Minor1] = rune2;
RunePage runepage3 = new("Juggler");
runepage3[Category.Major] = rune5;
runepage3[Category.Minor1] = rune3;
runepage3[Category.Minor2] = rune2;
await runeManager.AddItem(rune1);
await runeManager.AddItem(rune2);
await runeManager.AddItem(rune3);
await runeManager.AddItem(rune4);
await runeManager.AddItem(rune5);
await runeManager.AddItem(rune6);
await manager.AddItem(runepage1);
await manager.AddItem(runepage2);
await manager.AddItem(runepage3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
context.Database.EnsureCreated();
Assert.Equal(1, await manager.GetNbItemsByRune(rune1));
Assert.Equal(1, await manager.GetNbItemsByRune(rune6));
RunePage after = new("Hawk");
after[Category.Major] = rune1;
await manager.UpdateItem(new("Hawk"), after);
Assert.Equal(2, await manager.GetNbItemsByRune(rune1));
Assert.Equal(0, await manager.GetNbItemsByRune(rune6));
context.SaveChanges();
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
var runeManager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
Model.Rune rune4 = new("The moon", RuneFamily.Unknown);
Model.Rune rune5 = new("Radiance", RuneFamily.Domination);
Model.Rune rune6 = new("Bullseye", RuneFamily.Precision);
RunePage runepage1 = new("Damages");
runepage1[Category.Major] = rune1;
runepage1[Category.Minor1] = rune2;
runepage1[Category.Minor2] = rune5;
RunePage runepage2 = new("Hawk");
runepage2[Category.Major] = rune6;
runepage2[Category.Minor1] = rune2;
RunePage runepage3 = new("Juggler");
runepage3[Category.Major] = rune5;
runepage3[Category.Minor1] = rune3;
runepage3[Category.Minor2] = rune2;
await runeManager.AddItem(rune1);
await runeManager.AddItem(rune2);
await runeManager.AddItem(rune3);
await runeManager.AddItem(rune4);
await runeManager.AddItem(rune5);
await runeManager.AddItem(rune6);
await manager.AddItem(runepage1);
await manager.AddItem(runepage2);
await manager.AddItem(runepage3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunePagesMgr;
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
context.Database.EnsureCreated();
Assert.Equal(3, await manager.GetNbItems());
await manager.DeleteItem(new("Juggler"));
Assert.Equal(2, await manager.GetNbItems());
Assert.Equal(1, await manager.GetNbItemsByName("e"));
Assert.Equal(1, await manager.GetNbItemsByRune(rune2));
}
}
}
}

@ -0,0 +1,154 @@
using ManagersEF;
using EntityFrameworkLOL.Entities;
using EntityFrameworkLOL.DBContexts;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;
namespace TestEF
{
public class TestRunes
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
await manager.AddItem(rune1);
await manager.AddItem(rune2);
await manager.AddItem(rune3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
var nbItems = await manager.GetNbItems();
Assert.Equal(3, nbItems);
var items = await manager.GetItemsByName("Sanglante", 0, nbItems);
Assert.Equal("Sanglante", items.First().Name);
Assert.Equal(1, await manager.GetNbItemsByName("Concrétisation"));
items = await manager.GetItemsByFamily(RuneFamily.Precision, 0, nbItems);
Assert.Equal("Oeil de l'esprit", items.First().Name);
Assert.Equal(1, await manager.GetNbItemsByFamily(RuneFamily.Unknown));
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
await manager.AddItem(rune1);
await manager.AddItem(rune2);
await manager.AddItem(rune3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Assert.Equal(1, await manager.GetNbItemsByFamily(RuneFamily.Precision));
Model.Rune before = new("Concrétisation", RuneFamily.Unknown);
Model.Rune after = new("Concrétisation", RuneFamily.Precision);
await manager.UpdateItem(before, after);
Assert.Equal(2, await manager.GetNbItemsByFamily(RuneFamily.Precision));
context.SaveChanges();
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Model.Rune rune1 = new("Sanglante", RuneFamily.Domination);
Model.Rune rune2 = new("Oeil de l'esprit", RuneFamily.Precision);
Model.Rune rune3 = new("Concrétisation", RuneFamily.Unknown);
await manager.AddItem(rune1);
await manager.AddItem(rune2);
await manager.AddItem(rune3);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).RunesMgr;
context.Database.EnsureCreated();
Assert.Equal(3, await manager.GetNbItems());
await manager.DeleteItem(new("Concrétisation", RuneFamily.Unknown));
Assert.Equal(2, await manager.GetNbItems());
Assert.Equal(0, await manager.GetNbItemsByName("Concrétisation"));
}
}
}
}

@ -0,0 +1,182 @@
using ManagersEF;
using EntityFrameworkLOL.Entities;
using EntityFrameworkLOL.DBContexts;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;
namespace TestEF
{
public class TestSkins
{
[Fact]
public async void Test_Add()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
Skin batman_skin_1 = new("Batman de glace", batman);
Skin batman_skin_2 = new("Batman gold", batman);
Skin batman_skin_3 = new("L'homme araignée", batman);
Skin endeavor_skin_1 = new("L'abominable Endeavor", endeavor);
await manager.AddItem(batman_skin_1);
await manager.AddItem(batman_skin_2);
await manager.AddItem(batman_skin_3);
await manager.AddItem(endeavor_skin_1);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
context.Database.EnsureCreated();
var nbItems = await manager.GetNbItems();
Assert.Equal(4, nbItems);
Assert.Equal(4, (await manager.GetItems(0, nbItems)).Count());
var items = await manager.GetItemsByName("Batman", 0, nbItems);
Assert.Equal(2, items.Count());
Champion batman = new("Batman", ChampionClass.Assassin);
items = await manager.GetItemsByChampion(batman, 0, nbItems);
Assert.Equal(3, items.Count());
}
}
[Fact]
public async void Test_Update()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
Skin batman_skin_1 = new("Batman de glace", batman);
Skin batman_skin_2 = new("Batman gold", batman);
Skin batman_skin_3 = new("L'homme araignée", batman);
Skin endeavor_skin_1 = new("L'abominable Endeavor", endeavor);
await manager.AddItem(batman_skin_1);
await manager.AddItem(batman_skin_2);
await manager.AddItem(batman_skin_3);
await manager.AddItem(endeavor_skin_1);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
var itemsByName = await manager.GetItemsByChampion(batman, 0, 4);
Assert.Equal(3, itemsByName.Count());
Skin batman_skin = new("L'homme araignée", batman);
Skin endeavor_skin = new("L'homme araignée", endeavor);
await manager.UpdateItem(batman_skin, endeavor_skin);
itemsByName = await manager.GetItemsByChampion(batman, 0, 4);
Assert.Equal(2, itemsByName.Count());
context.SaveChanges();
}
}
[Fact]
public async void Test_Delete()
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<SQLiteContext>()
.UseSqlite(connection)
.Options;
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
var championManager = new EFManager(context).ChampionsMgr;
context.Database.EnsureCreated();
Champion batman = new("Batman", ChampionClass.Assassin);
Champion endeavor = new("Endeavor", ChampionClass.Tank);
await championManager.AddItem(batman);
await championManager.AddItem(endeavor);
Skin batman_skin_1 = new("Batman de glace", batman);
Skin batman_skin_2 = new("Batman gold", batman);
Skin batman_skin_3 = new("L'homme araignée", batman);
Skin endeavor_skin_1 = new("L'abominable Endeavor", endeavor);
await manager.AddItem(batman_skin_1);
await manager.AddItem(batman_skin_2);
await manager.AddItem(batman_skin_3);
await manager.AddItem(endeavor_skin_1);
}
using (var context = new SQLiteContext(options))
{
var manager = new EFManager(context).SkinsMgr;
context.Database.EnsureCreated();
await manager.DeleteItem((await manager.GetItemsByName("L'", 0, 4)).First());
await manager.DeleteItem((await manager.GetItemsByName("L'", 0, 3)).First());
Assert.Equal(2, await manager.GetNbItems());
Assert.Equal(2, await manager.GetNbItemsByName("Batman"));
Champion batman = new("Batman", ChampionClass.Assassin);
Assert.Equal(2, await manager.GetNbItemsByChampion(batman));
}
}
}
}

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\APILOL\APILOL.csproj" />
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,98 @@
using APILOL.Controllers;
using APILOL.Controllers.Request;
using APILOL.Controllers.v1;
using APILOL.Controllers.v2;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging.Abstractions;
using Model;
using StubLib;
using System.Web.Http;
using ChampionsController = APILOL.Controllers.v1.ChampionsController;
namespace TestUnitaire
{
[TestClass]
public class UnitTestChampion
{
private readonly ChampionsController controller;
private readonly StubData stub;
public UnitTestChampion()
{
stub = new StubData();
controller = new ChampionsController(stub, new NullLogger<ChampionsController>());
}
[TestMethod]
public async Task TestGet()
{
var champions = await controller.Get(new PageRequest());
//Assert
var resultObject = champions as OkObjectResult;
Assert.IsNotNull(resultObject);
var resultType = resultObject?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(resultType);
Assert.AreEqual(resultType.Count(), await stub.ChampionsMgr.GetNbItems());
}
[TestMethod]
public async Task TestPost()
{
//Arange
var champion = new ChampionDTO
{
Name = "Jinx",
Bio = "Awesome , great, fantastic Q",
};
//Act
var championsResult = await controller.Post(champion);
//Assert
var objectResult = championsResult as CreatedAtActionResult;
Assert.IsNotNull(objectResult);
var champions = objectResult?.Value as ChampionDTO;
Assert.IsNotNull(champions);
}
[TestMethod]
public async Task TestDelete()
{
//Arange
string championName = "Aatrox";
// Act
var result = await controller.Delete(championName);
// Assert
Assert.IsInstanceOfType(result, typeof(OkObjectResult));
Assert.IsTrue((await stub.ChampionsMgr.GetItemsByName(championName, 0, await stub.ChampionsMgr.GetNbItems())).Count() == 0);
}
[TestMethod]
public async Task TestUpdate()
{
//Arange
string championName = "Aatrox";
var updatedChampion = new ChampionDTO {Name = "Bibouuu", Bio = "Updated Bio" };
// Act
var result = await controller.PutAsync(championName, updatedChampion);
// Assert
Assert.IsInstanceOfType(result, typeof(OkResult));
Assert.IsNotNull(stub.ChampionsMgr.GetItemsByName("Bibouuu",0, await stub.ChampionsMgr.GetNbItems()));
}
}
}

@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;

@ -23,5 +23,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>
</Project>

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
namespace APILOL.Controllers
namespace TestsEF.Controllers
{
[ApiController]
[Route("[controller]")]

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59431",
"sslPort": 44385
}
},
"profiles": {
"TestsEF": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7027;http://localhost:5041",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
</Project>

@ -0,0 +1,13 @@
namespace TestsEF
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

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

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Loading…
Cancel
Save