Compare commits

..

87 Commits

Author SHA1 Message Date
6de23161e9 XD (#100)
XD

MD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-18 20:30:37 +01:00
5ccd28f815 fXDD (#99)
fXDD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-12 00:29:14 +01:00
4f0cf7906d grading (#98)
grading

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-11 21:48:41 +01:00
90e4c77da8 XD (#97)
XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-11 20:59:01 +01:00
9b3aff4dd0 5fb44c0b2c2818016e8c23d3 (#96)
Add approvals

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into 5fb44c0b2c2818016e8c23d3

XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-11 20:45:59 +01:00
11de1c5dfe XD (#95)
XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 22:12:44 +01:00
8f2baabaf2 fix (#94)
fix

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 22:10:11 +01:00
e558ca4b61 XD (#93)
XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 21:37:45 +01:00
de1cb296d3 feat/report (#92)
XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 21:34:12 +01:00
b68a8480bd feat/report (#91)
fix

fix

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 21:12:32 +01:00
2e1903429b Accept/Reject document 2021-01-10 19:21:41 +01:00
d612e74e13 ReportFields (#89)
XD

XD

XD

fix

rest

merge

 XD

XD

Co-authored-by: Michal Bohdanowicz <m.w.bohdanowicz@gmail.com>
2021-01-10 18:31:28 +01:00
520e986a55 PostmanTestRequest update 2021-01-10 09:40:30 +01:00
0ef4eeb0ac InternshipType and Documents added to list. ChangeStateComment field for accept and reject 2021-01-10 09:39:25 +01:00
6d8d7a7c0a Internship management 2021-01-09 22:11:55 +01:00
2779667ce8 snap 2020-11-28 22:16:34 +01:00
bc8410c89d Course requests 2020-11-28 22:09:44 +01:00
39a4c07a87 CourseController + new SearchArg for EditionSearchQuery 2020-11-27 00:10:39 +01:00
b9471fe26d Merge pull request 'Update '.build/deploy.sh'' (#84) from kadet-patch-3 into master 2020-11-15 13:42:52 +01:00
1ed5e53e73 Update '.build/deploy.sh' 2020-11-15 13:37:22 +01:00
e0359d579d Merge pull request 'Fast fix' (#83) from fixStaticPages into master 2020-11-14 23:01:02 +01:00
ca2d1aede4 Fast fix 2020-11-14 23:00:17 +01:00
4623127862 change endpoint to proper path (#82)
change endpoint to proper path

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-12 17:12:44 +01:00
9939f36900 fix/fix (#81)
fix/fix

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-12 01:15:55 +01:00
6d1103a6b9 fix/scan (#80)
form

dum dum

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-12 00:26:46 +01:00
2176fbe661 Postman endpoints tests 2020-11-08 13:28:49 +01:00
3a64467661 Refactor 2020-11-08 13:24:25 +01:00
78707bf3c5 Edition Create/Edit 2020-11-08 13:08:38 +01:00
74e3957274 Edition Get and Delete 2020-11-08 10:53:14 +01:00
df11ff9005 fix/whatervberve (#78)
fix

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-08 00:15:23 +01:00
42e3cb01f4 fix/whatervberve (#78)
add subjects

fix normal student login

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-08 00:05:48 +01:00
05fde36f41 Merge pull request 'Update 'src/InternshipSystem.Repository/DatabaseFiller.cs'' (#77) from kadet-patch-2 into master 2020-11-07 15:31:57 +01:00
37d9d68c82 Update 'src/InternshipSystem.Repository/DatabaseFiller.cs' 2020-11-07 15:31:48 +01:00
3c446802be Update filled internship types to match moodle ones (#76)
Update labels to match

Fix typo and references to entities

Update filled internship types to match moodle ones
2020-11-07 15:28:30 +01:00
4fa04557fb fix ifx (#75)
fix ifx

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-06 22:18:29 +01:00
78a1a53e3b fix (#74)
fix

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-06 21:43:20 +01:00
33149c255b fix internship registration (#73)
fix internship registration

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-06 21:29:37 +01:00
3b60331091 fix everything (#72)
fix everything

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-11-06 20:54:48 +01:00
80dda549bf fix double registration (#71)
fix double registration

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-27 20:57:20 +01:00
2da7349578 fix (#70)
fix

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-26 12:13:23 +01:00
3d5fa43135 scans (#69)
scans

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-25 22:30:05 +01:00
515f236632 change enum serialization (#68)
whatever

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-25 20:03:27 +01:00
976498dc50 change enum serialization (#68)
change enum serialization

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-18 11:19:50 +02:00
df1834d325 make proper result type for update (#67)
make proper result type for update

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-18 10:24:35 +02:00
6e7bdb72af feat/scan (#66)
scan fix

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into master

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into master

merge

add document scan endpoint

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-18 09:12:13 +02:00
614054acba feat/random (#65)
fix documents and other stuff

whatever

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into master

merge

add document scan endpoint

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-18 02:16:22 +02:00
2f6a1ab324 Merge pull request 'Fix migrations' (#64) from MigrationFix into master 2020-10-15 18:57:20 +02:00
ea191fd4d9 Fix migrations 2020-10-15 18:56:27 +02:00
0fadca7bb2 fix/migration (#63)
add migration

merge

add document scan endpoint

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-10 15:35:41 +02:00
102ec1feac add_hours (#62)
Add hours to registration

merge

add document scan endpoint

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-08 21:57:20 +02:00
7124b457dc feat/documents (#61)
add get scan endpoint

add document scan endpoint

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-08 19:27:45 +02:00
b98ab42c4d fix/endpoints (#60)
add

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into fix/endpoints

fix

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-04 13:30:28 +02:00
28859a601c fix (#59)
fix

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-04 12:48:29 +02:00
7d8e51212a clean up api bit (#58)
clean up api  bit

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-04 12:12:11 +02:00
1b80f058dc Merge pull request 'InternshipTypeNextFixes' (#57) from InternshipTypeNextFixes into master 2020-10-03 22:33:21 +02:00
589b6a7a04 new migration 2020-10-03 22:32:10 +02:00
e5868e4f63 InternshipType changes + new migration 2020-10-03 22:31:53 +02:00
603358c4eb endpoints ... 2020-10-03 21:38:52 +02:00
5ae4b983bb fix/tytokurwaniepotrafisznicporzadniezrobic (#55)
Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into fix/tytokurwaniepotrafisznicporzadniezrobic

KEK

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-03 00:36:49 +02:00
b4b05b7ef3 fix/tytokurwaniepotrafisznicporzadniezrobic (#55)
Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into fix/tytokurwaniepotrafisznicporzadniezrobic

KEK

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-02 23:21:08 +02:00
3a2b9b64d5 KEK (#54)
KEK

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-02 21:27:58 +02:00
8514e593fa doroboty (#53)
XDDDEEEE

gtfo

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into doroboty

finaly

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
2020-10-02 19:56:53 +02:00
0b27330931 Merge pull request 'Revert' (#52) from MoreEndpoints into master 2020-09-27 14:40:48 +02:00
74e0665aed Revert 2020-09-27 14:39:40 +02:00
e24e7e7471 Merge pull request 'One context again' (#51) from MoreEndpoints into master 2020-09-27 14:18:32 +02:00
2576fda4c8 One context again 2020-09-27 14:17:47 +02:00
eee47200f2 Merge pull request 'get edition info by guid fix + add course info' (#50) from MoreEndpoints into master 2020-09-27 12:24:15 +02:00
a06811fc9f get edition info by guid fix + add course info 2020-09-27 12:23:50 +02:00
1899b934b0 Merge pull request 'SubmitRegistrationForm - fixes' (#49) from MoreEndpoints into master 2020-09-27 12:03:46 +02:00
058d6d30bf SubmitRegistrationForm - fixes 2020-09-27 12:03:13 +02:00
12a1081c8d Merge pull request 'Fixes + GetCurrentEditionInternship' (#48) from MoreEndpoints into master 2020-09-27 11:26:33 +02:00
0d62134963 Fixes + GetCurrentEditionInternship 2020-09-27 11:25:03 +02:00
4963c8cbc4 Merge pull request 'longer EXPIRATION time' (#47) from MoreEndpoints into master 2020-09-27 09:11:34 +02:00
9991e4df5f longer EXPIRATION time 2020-09-27 09:10:44 +02:00
50f65cfe09 Merge pull request 'Auto migration next vesrion' (#46) from MoreEndpoints into master 2020-09-26 18:39:03 +02:00
12e952b0ce Auto migration next vesrion 2020-09-26 18:32:55 +02:00
09289183ab Merge pull request 'Auto migration mechanism - first attempt' (#45) from MoreEndpoints into master 2020-09-26 16:47:13 +02:00
1443abc391 Auto migration mechanism - first attempt 2020-09-26 16:45:38 +02:00
94ef521625 Merge pull request 'CRUD internshipType' (#44) from MoreEndpoints into master 2020-09-24 20:52:09 +02:00
78ebdbe33d CRUD internshipType 2020-09-24 20:51:18 +02:00
6d6cf68fe2 Merge pull request 'New static pages endpoints' (#43) from MoreEndpoints into master 2020-09-24 18:15:37 +02:00
d0972673d8 New static pages endpoints 2020-09-24 18:14:24 +02:00
7115060ebd Merge pull request 'SearchQuery changes + new student endpoints' (#41) from AnotherDbSet into master 2020-09-24 17:23:12 +02:00
02be2f9f2e SearchQuery changes + new student endpoints 2020-09-24 17:23:12 +02:00
0c58248d2a Merge pull request 'New DbContext and crud for companies' (#40) from AnotherDbSet into master 2020-09-23 12:40:42 +02:00
da052c19aa Student update current data and get current data 2020-09-23 12:38:44 +02:00
fa0448bef6 New DbContext and crud for companies 2020-09-23 09:18:54 +02:00
89 changed files with 7001 additions and 515 deletions

View File

@ -1,9 +1,4 @@
BUILD_PATH=$1
cd $BUILD_PATH/src || exit 1
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
cd $BUILD_PATH/.docker || exit 1
docker-compose up -d --build --force-recreate

View File

@ -8,12 +8,13 @@ services:
ASPNETCORE_ENVIRONMENT: Development
ASPNETCORE_URLS: http://+:80
SECURITYOPTIONS__SECRET: iewaiwie3aig9wi3chieBai9eephai
SECURITYOPTIONS__EXPIRATION: 20
SECURITYOPTIONS__EXPIRATION: 1440 # 24h in minutes
SECURITYOPTIONS__BASEURL: https://logowanie.pg.edu.pl
SECURITYOPTIONS__TOKENPATH: /oauth2.0/accessToken
SECURITYOPTIONS__PROFILEPATH: /oauth2.0/profile
SECURITYOPTIONS__CLIENTID: PraktykiClientId
SECURITYOPTIONS__REDIRECTURL: https://system-praktyk.stg.kadet.net/user/login/check/pg
FILLER__USE_DEFAULT_DATA: "true"
depends_on:
- db.postgres
ports:

View File

@ -0,0 +1,867 @@
{
"info": {
"_postman_id": "f0858747-6271-4176-9193-ed1f9be0d7d3",
"name": "StudentOperations",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "loginDev",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/dev/login",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"dev",
"login"
]
}
},
"response": []
},
{
"name": "GetInternshipManagementList",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/internship?OrderByField=InternshipState&SortOrder=Asc",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"internship"
],
"query": [
{
"key": "OrderByField",
"value": "InternshipState"
},
{
"key": "SortOrder",
"value": "Asc"
}
]
}
},
"response": []
},
{
"name": "GetInternshipManagement",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/internship/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"internship",
"1"
]
}
},
"response": []
},
{
"name": "GetInternshipManagementAccept",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "\"\""
},
"url": {
"raw": "http://localhost:8080/management/internship/accept/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"internship",
"accept",
"1"
]
}
},
"response": []
},
{
"name": "GetInternshipManagementReject",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "\"Co żeś odrąbał andzeju\""
},
"url": {
"raw": "http://localhost:8080/management/internship/reject/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"internship",
"reject",
"1"
]
}
},
"response": []
},
{
"name": "loginEdition",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTUyLCJleHAiOjE2MDEyODM5NTEsImlhdCI6MTYwMTE5NzU1Mn0.0wcNQSXV55MFvEnRLC09nGwCqI7M2kuWdwe0EOV_C6Y",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "\"138da8a3-855c-4b17-9bd2-5f357679efa9\""
},
"url": {
"raw": "http://localhost:8080/access/loginEdition",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"access",
"loginEdition"
]
}
},
"response": []
},
{
"name": "currentInternship",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8080/internshipRegistration",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"internshipRegistration"
]
}
},
"response": []
},
{
"name": "GetCourseList",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/course",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"course"
]
}
},
"response": []
},
{
"name": "GetCourse",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/course/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"course",
"1"
]
}
},
"response": []
},
{
"name": "CreateCourse",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"id\": null,\r\n \"name\": \"testowy\",\r\n \"nameEng\": \"test\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/management/course",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"course"
]
}
},
"response": []
},
{
"name": "UpdateCourse",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"id\": 3,\r\n \"name\": \"testowyUp\",\r\n \"nameEng\": \"testUp\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/management/course",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"course"
]
}
},
"response": []
},
{
"name": "DeleteCourse",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "DELETE",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/course/3",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"course",
"3"
]
}
},
"response": []
},
{
"name": "GetEditionManagementListByCourse",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/editions?course=1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"editions"
],
"query": [
{
"key": "course",
"value": "1"
}
]
}
},
"response": []
},
{
"name": "GetEditionManagementList",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/editions",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"editions"
]
}
},
"response": []
},
{
"name": "GetEditionManagement",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA0ODI3ODgzLCJleHAiOjE2MDQ5MTQyODMsImlhdCI6MTYwNDgyNzg4M30.a3mMm3Zk3xpfsmIwlqtpjgWgTNEXv8O4hH_V_L9UFZo",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/editions/138da8a3-855c-4b17-9bd2-5f357679efa9",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"editions",
"138da8a3-855c-4b17-9bd2-5f357679efa9"
]
}
},
"response": []
},
{
"name": "CreateEdition",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"editionStart\": \"2020-11-15T11:02:04.002Z\",\r\n \"editionFinish\": \"2020-11-25T11:02:04.002Z\",\r\n \"reportingStart\": \"2020-11-20T11:02:04.002Z\",\r\n \"course\": {\r\n \"id\": 1,\r\n \"name\": \"Informatyka\",\r\n \"nameEng\": \"Informatics\"\r\n },\r\n \"availableSubjectsIds\": [2],\r\n \"availableInternshipTypesIds\": [8]\r\n}"
},
"url": {
"raw": "http://localhost:8080/management/edition",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"edition"
]
}
},
"response": []
},
{
"name": "UpdateEdition",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA2NTk2MzI5LCJleHAiOjE2MDY2ODI3MjksImlhdCI6MTYwNjU5NjMyOX0.O-dLJNI3-tNj96xOpz8LE7zrysmJkN069A3Zku2A7S0",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"id\": \"138da8a3-855c-4b17-9bd2-5f357679efa9\",\r\n \"editionStart\": \"2020-11-15T11:02:04.002Z\",\r\n \"editionFinish\": \"2020-11-20T11:02:04.002Z\",\r\n \"reportingStart\": \"2020-11-17T11:02:04.002Z\",\r\n \"course\": {\r\n \"id\": 2,\r\n \"name\": \"Inżynieria Biomedyczna\",\r\n \"nameEng\": \"Biomedical Engineering\"\r\n },\r\n \"availableSubjectsIds\": [3],\r\n \"availableInternshipTypesIds\": [3]\r\n}"
},
"url": {
"raw": "http://localhost:8080/management/editions",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"editions"
]
}
},
"response": []
},
{
"name": "DeleteEditionManagement",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjA0ODI3ODgzLCJleHAiOjE2MDQ5MTQyODMsImlhdCI6MTYwNDgyNzg4M30.a3mMm3Zk3xpfsmIwlqtpjgWgTNEXv8O4hH_V_L9UFZo",
"type": "string"
}
]
},
"method": "DELETE",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/management/editions/be1a4439-0360-477c-85c5-e28bc8542883",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"management",
"editions",
"be1a4439-0360-477c-85c5-e28bc8542883"
]
}
},
"response": []
},
{
"name": "updateRegistration",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"company\": {\r\n \"id\": 1,\r\n \"nip\": null,\r\n \"name\": null\r\n },\r\n \"branchOffice\": {\r\n \"id\": 1,\r\n \"street\": null,\r\n \"building\": null,\r\n \"city\": null,\r\n \"postalCode\": null,\r\n \"country\": null\r\n },\r\n \"start\": \"2020-07-27T09:43:49.094Z\",\r\n \"end\": \"2020-09-27T09:43:49.094Z\",\r\n \"type\": {\r\n \"id\": 2,\r\n \"type\": null,\r\n \"description\": null,\r\n \"descriptionEng\": null\r\n }\r\n}"
},
"url": {
"raw": "http://localhost:8080/internshipRegistration",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"internshipRegistration"
]
}
},
"response": []
},
{
"name": "GetRegisteredEditions",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8080/editions",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"editions"
]
}
},
"response": []
},
{
"name": "GetEditionsConfiguration",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "http://localhost:8080/editions/138da8a3-855c-4b17-9bd2-5f357679efa9",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"editions",
"138da8a3-855c-4b17-9bd2-5f357679efa9"
]
}
},
"response": []
},
{
"name": "RegisterForEdition",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjAxMTk3NTYzLCJleHAiOjE2MDEyODM5NjMsImlhdCI6MTYwMTE5NzU2MywiRWRpdGlvbiI6IjEzOGRhOGEzLTg1NWMtNGIxNy05YmQyLTVmMzU3Njc5ZWZhOSJ9.l7QK1eUIJexnDaFKZ9yx3NWxmB2KrvPpjLUuuP1EJyE",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "\"138da8a3-855c-4b17-9bd2-5f357679efa9\""
},
"url": {
"raw": "http://localhost:8080/register",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"register"
]
}
},
"response": []
}
]
}

49
README.MD Normal file
View File

@ -0,0 +1,49 @@
# Uruchomienie
Aby uruchomić środowisko deweloperskie wystarczy
```bash
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
docker-compose -f ./.docker/docker-compose.yaml --build --volumes
```
# Opis struktury
Opis struktury projektu
## src/
zawiera kod podzielony na 3 projekty
- Api - Definicja interfejsu wystawianego dla częsci frontendowej
- Core - Logika biznesowa aplikacji, definicja domeny.
- Repository - Definicja repozytorium EFCore
## test/
Zawiera testy jednostkowe projektu. Przy pisaniu wykorzystano Machine-Specification
## .build/
Folder zawierający pliki definiujące CI/CD projektu
## .docker/
Folder zawiera pliki docker-compose przeznaczone do uruchamiania środowiska deweloperskiego, stanowiące również dokumentacje zmiennych środowiskowych konfigurujących projekt
```yaml
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=password"
ASPNETCORE_ENVIRONMENT: Development
ASPNETCORE_URLS: http://+:80
SECURITYOPTIONS__SECRET: secret
SECURITYOPTIONS__EXPIRATION: 1440 # 24h in minutes
SECURITYOPTIONS__BASEURL: https://logowanie.pg.edu.pl
SECURITYOPTIONS__TOKENPATH: /oauth2.0/accessToken
SECURITYOPTIONS__PROFILEPATH: /oauth2.0/profile
SECURITYOPTIONS__CLIENTID: PraktykiClientId
SECURITYOPTIONS__REDIRECTURL: https://system-praktyk.net/user/login/check/pg
```
## props/
Folder ze współdzieloną konfiguracją dla grup projektów, np. wersji bibliotek używanych przy pisaniu testów.

View File

@ -1,5 +0,0 @@
{
"sdk": {
"version": "3.1.301"
}
}

View File

@ -3,6 +3,7 @@ using AutoMapper;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Result;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -18,10 +19,27 @@ namespace InternshipSystem.Api
.ForMember(
result => result.Status,
opt => opt.MapFrom(edition => edition.IsOpen ? "Open" : "Archival"));
CreateMap<Edition, EditionManagementResult>();
CreateMap<Edition, EditionDetailsResult>();
CreateMap<Edition, EditionConfigurationResult>();
CreateMap<InternshipSubject, InternshipSubject>();
CreateMap<EditionSubject, InternshipSubject>().IncludeMembers(es => es.Subject);
CreateMap<EditionSubject, InternshipSubject>()
.IncludeMembers(es => es.Subject);
CreateMap<EditionInternshipType, InternshipType>()
.IncludeMembers(eit => eit.InternshipType);
CreateMap<ReportFieldEdition, ReportField>()
.IncludeMembers(e => e.Field);
CreateMap<ReportField, ReportField>();
CreateMap<InternshipType, InternshipType>();
}
}
}

View File

@ -1,17 +1,20 @@
using System;
using System.Collections.Generic;
using IdentityServer4.Extensions;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core.Commands
namespace InternshipSystem.Api.Commands
{
public class UpdateRegistrationForm
{
public UpdateCompany? Company { get; set; }
public DateTime? Start { get; set; }
public DateTime? End { get; set; }
public InternshipType Type { get; set; }
public UpdateMentor Mentor { get; set; }
public List<InternshipSubject> Subjects { get; set; }
public UpdateMentor? Mentor { get; set; }
public List<long> Subjects { get; set; }
public int? Hours { get; set; }
public long? Type { get; set; }
}
public struct UpdateMentor
@ -28,8 +31,8 @@ namespace InternshipSystem.Core.Commands
public string Nip { get; set; }
public string Name { get; set; }
public UpdateBranchOffice? BranchOffice { get; set; }
public bool IsUpdate => Id.HasValue;
public bool IsCustomUpdate => !Nip.IsNullOrEmpty() || !Name.IsNullOrEmpty();
}
public struct UpdateBranchOffice
@ -40,5 +43,11 @@ namespace InternshipSystem.Core.Commands
public string City { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public bool IsCustomUpdate => !string.IsNullOrEmpty(Street) ||
!string.IsNullOrEmpty(Building) ||
!string.IsNullOrEmpty(City) ||
!string.IsNullOrEmpty(PostalCode) ||
!string.IsNullOrEmpty(Country);
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading;
@ -12,7 +11,6 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Serilog;
namespace InternshipSystem.Api.Controllers
{
@ -38,13 +36,19 @@ namespace InternshipSystem.Api.Controllers
}
[HttpGet("login")]
public async Task<ActionResult> Authenticate(string code, CancellationToken cancellationToken)
[HttpPost("login")]
public async Task<ActionResult> Authenticate([FromBody] string code, CancellationToken cancellationToken)
{
var token = await _loginClient.GetCasTokenAsync(code, cancellationToken);
var casData = await _loginClient.GetProfileAsync(token, cancellationToken);
var student = await _context.Students.FirstOrDefaultAsync(s => s.Id == long.Parse(casData.PersonNumber));
if (!long.TryParse(casData.PersonNumber, out var id))
{
return BadRequest();
}
var student = await _context.Students.FirstOrDefaultAsync(s => s.Id == id, cancellationToken: cancellationToken);
if (student == null)
{
@ -76,9 +80,9 @@ namespace InternshipSystem.Api.Controllers
return Ok(_tokenService.generateToken(identity));
}
[HttpGet("loginEdition")]
[HttpPost("loginEdition")]
[Authorize]
public async Task<ActionResult> LoginIntoEdition(Guid editionId, [FromServices] User user, CancellationToken token)
public async Task<ActionResult> LoginIntoEdition([FromBody] Guid editionId, [FromServices] User user, CancellationToken token)
{
var edition = await _context.Editions.FindAsync(editionId);
@ -98,7 +102,7 @@ namespace InternshipSystem.Api.Controllers
return Ok(_tokenService.generateToken(newIdentity));
}
private Student CreateStudentWithCasData(CasUserData casData)
{
var id = long.Parse(casData.PersonNumber);

View File

@ -1,4 +1,3 @@
using System.Threading.Tasks;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Mvc;
@ -16,42 +15,39 @@ namespace InternshipSystem.Api.Controllers
public DatabaseFiller FillerService { get; }
[HttpPost("fill")]
public async Task<IActionResult> Fill()
{
await FillerService.FillCompanies();
await FillerService.FillInternshipTypes();
await FillerService.FillEditions();
await FillerService.FillStaticPages();
return Ok();
}
[HttpPost("fill/companies")]
public async Task<IActionResult> FillCompaniesAsync()
{
await FillerService.FillCompanies();
return Ok();
}
[HttpPost("fill/internshipTypes")]
public async Task<IActionResult> FillInternshipTypesAsync()
{
await FillerService.FillInternshipTypes();
return Ok();
}
[HttpPost("fill/editions")]
public async Task<IActionResult> FillEditionsAsync()
{
await FillerService.FillEditions();
return Ok();
}
[HttpPost("fill/staticPages")]
public async Task<IActionResult> FillStaticPagesAsync()
{
await FillerService.FillStaticPages();
return Ok();
}
// [HttpPost("fill")]
// public async Task<IActionResult> FillAll()
// {
// await FillerService.FillAll();
// return Ok();
// }
//
// [HttpPost("fill/companies")]
// public async Task<IActionResult> FillCompaniesAsync()
// {
// await FillerService.FillCompanies();
// return Ok();
// }
//
// [HttpPost("fill/internshipTypes")]
// public async Task<IActionResult> FillInternshipTypesAsync()
// {
// await FillerService.FillInternshipTypes();
// return Ok();
// }
//
// [HttpPost("fill/editions")]
// public async Task<IActionResult> FillEditionsAsync()
// {
// await FillerService.FillEditions();
// return Ok();
// }
//
// [HttpPost("fill/staticPages")]
// public async Task<IActionResult> FillStaticPagesAsync()
// {
// await FillerService.FillStaticPages();
// return Ok();
// }
}
}

View File

@ -3,11 +3,15 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Queries.SearchQuery;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using static System.String;
namespace InternshipSystem.Api.Controllers
{
@ -19,19 +23,24 @@ namespace InternshipSystem.Api.Controllers
{
Context = context;
}
private InternshipDbContext Context { get; }
/// <summary>
/// Get companies matching provided paginated query
/// </summary>
/// <param name="searchQuery">Paginated query description</param>
/// <response code="200">Successfully retrieved Companies</response>
/// <response code="400">Search query was malformed</response>
/// <returns>Part of companies collection</returns>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IReadOnlyCollection<Company>> SearchByNameAsync([FromQuery] SearchQuery searchQuery, CancellationToken cancellationToken) =>
[Authorize]
public async Task<ActionResult<IReadOnlyCollection<Company>>> SearchByNameAsync([FromQuery] CompanySearchQuery searchQuery, [FromServices] User user, CancellationToken cancellationToken) =>
await Context.Companies
.Where(c => c.Name.ToLower().Contains(searchQuery.Query.ToLower()))
.Where(c => c.Name.ToLower().Contains(searchQuery.Name.ToLower()))
.Where(c => c.Provider == 0 || c.Provider == user.PersonNumber)
.OrderBy(o => o.Name)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
@ -48,18 +57,200 @@ namespace InternshipSystem.Api.Controllers
[HttpGet("{companyId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<IReadOnlyCollection<BranchOffice>> SearchBranchesByAddress([FromQuery] SearchQuery searchQuery, long companyId, CancellationToken token)
[Authorize]
public async Task<ActionResult<IReadOnlyCollection<BranchOffice>>> SearchBranchesByAddress([FromQuery] BranchOfficeSearchQuery searchQuery, long companyId, [FromServices] User user, CancellationToken token)
{
var company = await Context.Companies.Where(c => c.Id == companyId).FirstAsync(token);
return await Context.Entry(company)
.Collection(c => c.Branches)
.Query()
.Where(office => office.Address.City.Contains(searchQuery.Query.ToLower()))
.Where(office => office.Address.City.ToLower().Contains(searchQuery.City.ToLower()))
.Where(office => office.Provider == 0 || office.Provider == user.PersonNumber)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(token);
}
}
/// <summary>
/// Updates or add new company (if not new than contains id)
/// </summary>
/// <param name="companyForm"></param>
/// <response code="200">Successfully updated company</response>
/// <response code="400">Company form was malformed</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Company not found</response>
/// <returns></returns>
[HttpPut]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> UpsertCompany([FromBody] CompanyForm companyForm, CancellationToken cancellationToken)
{
var validator = new CompanyForm.Validator();
var validationResult = await validator.ValidateAsync(companyForm, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
if (companyForm.Id.HasValue)
{
var companyToUpdate = await Context.Companies.FindAsync(companyForm.Id.Value);
if (companyToUpdate == null)
{
return NotFound();
}
companyToUpdate.Name = IsNullOrEmpty(companyForm.Name) ? companyToUpdate.Name : companyForm.Name;
companyToUpdate.Nip = IsNullOrEmpty(companyForm.Nip) ? companyToUpdate.Nip : companyForm.Nip;
}
else
{
var newCompany = Company.CreateCompany(companyForm.Nip, companyForm.Name);
await Context.Companies.AddAsync(newCompany, cancellationToken);
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
/// <summary>
/// Deletes existing company by id
/// </summary>
/// <param name="companyId"></param>
/// <response code="200">Successfully deleted company</response>
/// <response code="400">Company id is empty</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Company not found</response>
/// <returns></returns>
[HttpDelete("{companyId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> DeleteCompany(long companyId, CancellationToken cancellationToken)
{
var companyToDelete = await Context.Companies
.Include(c => c.Branches)
.FirstOrDefaultAsync(c => c.Id == companyId, cancellationToken);
if (companyToDelete == null)
{
return NotFound();
}
Context.Companies.Remove(companyToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
/// <summary>
/// Updates or add new branchOffice (if not new than contains id)
/// </summary>
/// <param name="branchOfficeForm"></param>
/// <param name="companyId"></param>
/// <response code="200">Successfully updated company branch office</response>
/// <response code="400">Branch office was malformed</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Company or branch office not found</response>
/// <returns></returns>
[HttpPut("{companyId}/branchOffices")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> UpdateBranch([FromBody] BranchOfficeForm branchOfficeForm, long companyId, CancellationToken cancellationToken)
{
var validator = new BranchOfficeForm.Validator();
var validationResult = await validator.ValidateAsync(branchOfficeForm, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
var company = await Context.Companies
.Include(c => c.Branches)
.FirstOrDefaultAsync(c => c.Id == companyId, cancellationToken);
if (company == null)
{
return NotFound();
}
if (branchOfficeForm.Id.HasValue)
{
var branchOffice = company.Branches.First(b => b.Id == branchOfficeForm.Id);
if (branchOffice == null)
{
return NotFound();
}
branchOffice.Address.Country = IsNullOrEmpty(branchOfficeForm.Country) ? branchOffice.Address.Country : branchOfficeForm.Country;
branchOffice.Address.City = IsNullOrEmpty(branchOfficeForm.City) ? branchOffice.Address.City : branchOfficeForm.City;
branchOffice.Address.PostalCode = IsNullOrEmpty(branchOfficeForm.PostalCode) ? branchOffice.Address.PostalCode : branchOfficeForm.PostalCode;
branchOffice.Address.Street = IsNullOrEmpty(branchOfficeForm.Street) ? branchOffice.Address.Street : branchOfficeForm.Street;
branchOffice.Address.Building = IsNullOrEmpty(branchOfficeForm.Building) ? branchOffice.Address.Building : branchOfficeForm.Building;
}
else
{
var newBranchOffice = new BranchOffice
{
Address = new BranchAddress
{
Country = branchOfficeForm.Country,
City = branchOfficeForm.City,
PostalCode = branchOfficeForm.PostalCode,
Street = branchOfficeForm.Street,
Building = branchOfficeForm.Building,
}
};
company.Branches.Add(newBranchOffice);
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
/// <summary>
/// Deletes existing branchOffice
/// </summary>
/// <param name="branchOfficeId"></param>
/// <response code="200">Successfully deleted company branch office</response>
/// <response code="400">Branch office id is empty</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Company or branch office not found</response>
[HttpDelete("{companyId}/branchOffice/{branchOfficeId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> DeleteBranch(long companyId, long branchOfficeId, CancellationToken cancellationToken)
{
var company =
await Context.Companies
.Include(c => c.Branches)
.Where(c => c.Id == companyId)
.FirstOrDefaultAsync(cancellationToken);
if (company == null)
{
return NotFound();
}
var branchOffice = company.Branches.RemoveAll(b => b.Id == branchOfficeId);
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
}
}

View File

@ -0,0 +1,127 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("management/course")]
public class CourseController : ControllerBase
{
private InternshipDbContext Context { get; }
public CourseController(InternshipDbContext context)
{
Context = context;
}
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult<IReadOnlyCollection<Course>>> GetCourses(CancellationToken cancellationToken) =>
await Context.Courses
.ToListAsync(cancellationToken);
[HttpGet("{courseId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult<Course>> GetCourse(long courseId, CancellationToken cancellationToken)
{
var course = await Context.Courses
.Where(c => c.Id == courseId)
.FirstOrDefaultAsync(cancellationToken);
if (course == null)
{
return NotFound();
}
return Ok(course);
}
[HttpPut]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> UpsertCourse([FromBody] CourseForm courseForm, CancellationToken cancellationToken)
{
var validator = new CourseForm.Validator();
var validationResult = await validator.ValidateAsync(courseForm, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
if (courseForm.Id.HasValue)
{
var course = await Context.Courses.FindAsync(courseForm.Id.Value);
if (course == null)
{
return NotFound();
}
course.UpdateCourse(courseForm.Name, courseForm.NameEng);
}
else
{
var newCourse = Course.CreateCourse(courseForm.Name, courseForm.NameEng);
await Context.Courses.AddAsync(newCourse, cancellationToken);
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
[HttpDelete("{courseId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> DeleteCourse(long courseId, CancellationToken cancellationToken)
{
var courseToDelete = await Context.Courses
.Where(c => c.Id == courseId)
.FirstOrDefaultAsync(cancellationToken);
if (courseToDelete == null)
{
return NotFound();
}
var referencedEditions =
await Context.Editions
.Include(e => e.Course)
.Where(e => e.Course.Id == courseToDelete.Id)
.CountAsync(cancellationToken);
if (referencedEditions > 0)
{
return Conflict();
}
Context.Courses.Remove(courseToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
}
}

View File

@ -0,0 +1,110 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("management/document")]
public class DocumentManagementController : ControllerBase
{
private InternshipDbContext Context { get; }
public DocumentManagementController(InternshipDbContext context)
{
Context = context;
}
[HttpDelete("{documentId}/delete")]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> DeleteDocument(long documentId, CancellationToken ct)
{
var internship = await Context.Internships
.Include(i => i.Documentation)
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), ct);
if (internship == null)
{
return NotFound();
}
internship.RemoveDocument(documentId);
await Context.SaveChangesAsync(ct);
return Ok();
}
[HttpPut("{documentId}/accept")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> AcceptDocument(long documentId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.Documentation)
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), token);
if (internship == null)
{
return NotFound();
}
var document = internship.Documentation
.FirstOrDefault(d => d.Id.Equals(documentId));
if (document == null)
{
return NotFound();
}
document.State = DocumentState.Accepted;
document.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
await Context.SaveChangesAsync(token);
return Ok();
}
[HttpPut("{documentId}/reject")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> RejectDocument(long documentId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.Documentation)
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), token);
if (internship == null)
{
return NotFound();
}
var document = internship.Documentation
.FirstOrDefault(d => d.Id.Equals(documentId));
if (document == null)
{
return NotFound();
}
document.State = DocumentState.Rejected;
document.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
await Context.SaveChangesAsync(token);
return Ok();
}
}
}

View File

@ -1,11 +1,18 @@
using System.Threading;
using System;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.Services;
using InternshipSystem.Api.Service;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
@ -13,18 +20,19 @@ namespace InternshipSystem.Api.Controllers
[Route("document")]
public class DocumentsController : ControllerBase
{
private readonly IInternshipService _internshipService;
private readonly InternshipDbContext _context;
private readonly FileValidator _fileValidator;
public DocumentsController(IInternshipService internshipService)
public DocumentsController(InternshipDbContext context, FileValidator fileValidator)
{
_internshipService = internshipService;
_context = context;
_fileValidator = fileValidator;
}
/// <summary>
/// Fill out required document,
/// </summary>
/// <param name="documentRequest">Documents Scan and description, and Id of filled document</param>
/// <returns></returns>
/// <response code="200">If change was successfully registered</response>
/// <response code="400">If the provided query was malformed</response>
/// <response code="404">Id doesn't match any required document</response>
@ -35,18 +43,139 @@ namespace InternshipSystem.Api.Controllers
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest,
[FromServices] User user, CancellationToken cancellationToken)
public async Task<ActionResult> AddDocumentToInternship(
[FromBody] DocumentPublishRequest documentRequest,
[FromServices] User user,
CancellationToken cancellationToken)
{
var validator = new DocumentPublishRequest.Validator();
var validationResult = await validator.ValidateAsync(documentRequest, cancellationToken);
if (!validationResult.IsValid)
var result = await validator.ValidateAsync(documentRequest, cancellationToken);
if (!result.IsValid)
{
return BadRequest(validationResult.ToString());
return BadRequest(result.ToString());
}
return await _internshipService.AddDocumentToInternship(documentRequest, user.PersonNumber, cancellationToken);
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship =
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Documentation)
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
try
{
internship.AddNewDocument(documentRequest.Description, documentRequest.Type);
await _context.SaveChangesAsync(cancellationToken);
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
return Ok(internship.Documentation.First(d => d.Type == documentRequest.Type));
}
[HttpPut("{documentId}/scan")]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> AddDocumentScan(long documentId, IFormFile documentScan, [FromServices] User user, CancellationToken cancellationToken)
{
await using var memoryStream = new MemoryStream();
await documentScan.CopyToAsync(memoryStream, cancellationToken);
if (!_fileValidator.IsValidFile(memoryStream.ToArray()))
{
return BadRequest("error.document.scan");
}
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship =
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Documentation)
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
var document = await _context.Entry(internship)
.Collection(i => i.Documentation)
.Query()
.Include(d => d.Scan)
.FirstAsync(d => d.Id == documentId, cancellationToken);
document.Scan ??= new DocumentScan();
document.Scan.Size = memoryStream.Length;
document.Scan.Filename = documentScan.FileName;
document.Scan.Mime = _fileValidator.GetFileMime(memoryStream.ToArray());
document.Scan.File = memoryStream.ToArray();
document.State = DocumentState.Submitted;
await _context.SaveChangesAsync(cancellationToken);
return Ok();
}
[HttpGet("{documentId}/scan/download")]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> GetDocumentScan(long documentId, [FromQuery] string disposition, [FromServices] User user, CancellationToken cancellationToken)
{
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship =
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
var document =
await _context.Entry(internship)
.Collection(i => i.Documentation)
.Query()
.Include(d => d.Scan)
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
var stream = new MemoryStream(document.Scan.File);
Response.Headers.Add("Content-Disposition", new ContentDisposition
{
Inline = disposition == "inline",
FileName = document.Scan.Filename,
Size = document.Scan.Size
}.ToString());
return File(stream, document.Scan.Mime);
}
[HttpGet("{documentId}/scan")]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> GetDocumentScanData(long documentId, [FromServices] User user, CancellationToken cancellationToken)
{
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship =
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
var scan =
await _context.Entry(internship)
.Collection(i => i.Documentation)
.Query()
.Include(d => d.Scan)
.Select(s => new {s.Id, s.Scan.Filename, s.Scan.Mime, s.Scan.Size})
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
if (scan == null)
{
return NotFound();
}
return Ok(scan);
}
}
}

View File

@ -38,7 +38,7 @@ namespace InternshipSystem.Api.Controllers
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult<IList<EditionResult>>> GetAvailableEditions([FromServices] User user, CancellationToken token)
public async Task<ActionResult<IEnumerable<EditionResult>>> GetAvailableEditions([FromServices] User user, CancellationToken token)
{
var editions =
await Context.Editions
@ -57,22 +57,52 @@ namespace InternshipSystem.Api.Controllers
}
/// <summary>
/// Get edition's configuration
/// Get accessible editions
/// </summary>
/// <response code="200">Editions accessible by the current user</response>
/// <response code="401">This action is only available for authorized student</response>
/// <response code="404"/>
/// <returns></returns>
[HttpGet("{id}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<EditionResult>> GetEditionInfo(Guid id, CancellationToken token)
{
var edition =
await Context.Editions
.Where(e => e.Id == id)
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
.FirstOrDefaultAsync(token);
if (edition == null)
{
return NotFound();
}
return Ok(edition);
}
/// <summary>
/// Get current edition's configuration
/// </summary>
/// <response code="200">Parameters of edition registered for by student</response>
/// <response code="401">This action is only available for authorized student registered for this edition edition</response>
/// <response code="404">Specified edition doesn't exist</response>
/// <returns></returns>
[HttpGet("{id}")]
[HttpGet("current")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration(Guid id, CancellationToken token)
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration([FromServices] User user, CancellationToken token)
{
var edition =
await Context.Editions
.Include(e => e.AvailableSubjects)
.Where(e => e.Id.Equals(id))
.Include(e => e.ReportSchema)
.ThenInclude(e => e.Field)
.Include(e => e.Course)
.Where(e => e.Id == user.EditionId)
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
.FirstOrDefaultAsync(token);

View File

@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Queries.SearchQuery;
using InternshipSystem.Api.Result;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("management/editions")]
public class EditionManagementController : ControllerBase
{
private InternshipDbContext Context { get; }
private IMapper Mapper { get; }
public EditionManagementController(IMapper mapper, InternshipDbContext context)
{
Context = context;
Mapper = mapper;
}
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult<IReadOnlyCollection<EditionManagementResult>>> GetEditions([FromQuery] EditionSearchQuery searchQuery, CancellationToken token) =>
await Context.Editions
.Include(e => e.Course)
.Where(p => !searchQuery.Course.HasValue || p.Course.Id == searchQuery.Course)
.ProjectTo<EditionManagementResult>(Mapper.ConfigurationProvider)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(token);
[HttpGet("{editionId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult<EditionDetailsResult>> GetFullEdition(Guid editionId, CancellationToken token)
{
var edition = await Context.Editions
.Include(e => e.Course)
.Include(e => e.AvailableSubjects)
.ThenInclude(s => s.Subject)
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(i => i.InternshipType)
.Include(e => e.ReportSchema)
.ThenInclude(er => er.Field)
.Where(e => e.Id == editionId)
.ProjectTo<EditionDetailsResult>(Mapper.ConfigurationProvider)
.FirstOrDefaultAsync(token);
if (edition == null)
{
return NotFound();
}
return Ok(edition);
}
[HttpPut]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> UpsertEdition(EditionForm editionForm, CancellationToken token)
{
var validator = new EditionForm.Validator();
var validationResult = await validator.ValidateAsync(editionForm, token);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
if (editionForm.Id.HasValue)
{
var editionToUpdate = await Context.Editions
.Include(e => e.AvailableSubjects)
.Include(e => e.AvailableInternshipTypes)
.Include(e => e.ReportSchema)
.FirstOrDefaultAsync(e => e.Id == editionForm.Id.Value, token);
if (editionToUpdate == null)
{
return NotFound();
}
editionToUpdate.UpdateEdition(editionForm.EditionStart, editionForm.EditionFinish, editionForm.ReportingStart,
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
if (!editionToUpdate.IsValidDates)
{
return BadRequest();
}
}
else
{
var newEdition =
Edition.CreateEdition(editionForm.EditionStart.Value, editionForm.EditionFinish.Value, editionForm.ReportingStart.Value,
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
if (!newEdition.IsValidDates)
{
return BadRequest();
}
await Context.Editions.AddAsync(newEdition, token);
}
await Context.SaveChangesAsync(token);
return Ok();
}
[HttpDelete("{editionId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> DeleteEdition(Guid editionId, CancellationToken token)
{
var editionToDelete = await Context.Editions
.Include(e => e.AvailableSubjects)
.Include(e => e.AvailableInternshipTypes)
.Include(e => e.ReportSchema)
.FirstOrDefaultAsync(e => e.Id.Equals(editionId), token);
if (editionToDelete == null)
{
return NotFound();
}
var referencedInternships =
await Context
.Entry(editionToDelete)
.Collection(e => e.Internships)
.Query()
.CountAsync(token);
if (referencedInternships > 0)
{
return Conflict();
}
Context.Editions.Remove(editionToDelete);
await Context.SaveChangesAsync(token);
return Ok();
}
}
}

View File

@ -0,0 +1,56 @@
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Security;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("internship")]
public class InternshipController : ControllerBase
{
private readonly InternshipDbContext _context;
public InternshipController(InternshipDbContext context)
{
_context = context;
}
/// <summary>
/// Get internship for current edition
/// </summary>
/// <response code="200">If current internship returned successfully</response>
/// <response code="401">This action is only available for authorized student registered for current edition</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult<Internship>> GetCurrentEditionInternship([FromServices] User user, CancellationToken cancellationToken)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Student)
.Include(i => i.InternshipRegistration)
.Include(i => i.InternshipRegistration.Company)
.Include(i => i.InternshipRegistration.BranchAddress)
.Include(i => i.InternshipRegistration.Type)
.Include(i => i.InternshipRegistration.Subjects)
.ThenInclude(subject => subject.Subject)
.Include(i => i.Report)
.Include(i => i.Documentation)
.SingleAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
return Ok(internship);
}
}
}

View File

@ -0,0 +1,190 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries.SearchQuery;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("management/internship")]
public class InternshipManagementController : ControllerBase
{
private InternshipDbContext Context { get; }
public InternshipManagementController(InternshipDbContext context)
{
Context = context;
}
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult<IReadOnlyCollection<Internship>>> GetInternships([FromQuery] InternshipSearchQuery searchQuery, CancellationToken token)
{
var query =
Context.Internships
.Include(i => i.Edition)
.Include(i => i.InternshipRegistration)
.Include(i => i.InternshipRegistration.Type)
.Include(i => i.Student)
.Include(i => i.Documentation)
.Include(i => i.Report)
.Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id == searchQuery.EditionId)
.Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State == searchQuery.InternshipState)
.Where(i => !searchQuery.InternshipState.HasValue || i.Report.State == searchQuery.ReportState)
.Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber == searchQuery.StudentAlbumNumber)
.Where(i => string.IsNullOrEmpty(searchQuery.StudentFirstName) || i.Student.FirstName.ToLower().Contains(searchQuery.StudentFirstName.ToLower()))
.Where(i => string.IsNullOrEmpty(searchQuery.StudentLastName) || i.Student.LastName.ToLower().Contains(searchQuery.StudentLastName.ToLower()))
.Where(i => !searchQuery.DocumentWithState.HasValue || i.Documentation.Any(d => d.State == searchQuery.DocumentWithState))
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage);
if (searchQuery.OrderByField.ToLower().Equals("date"))
{
query = searchQuery.SortOrder.Equals(SortOrder.Desc) ?
query.OrderByDescending(i => i.InternshipRegistration.SubmissionDate) :
query.OrderBy(i => i.InternshipRegistration.SubmissionDate);
}
else if (searchQuery.OrderByField.ToLower().Equals("internshipstate"))
{
query = searchQuery.SortOrder.Equals(SortOrder.Desc) ?
query.OrderByDescending(i => i.InternshipRegistration.State) :
query.OrderBy(i => i.InternshipRegistration.State);
}
var result = await query.ToListAsync(token);
return Ok(result);
}
[HttpGet("{internshipId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult<Internship>> GetInternship(long internshipId, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.Student)
.Include(i => i.InternshipRegistration)
.Include(i => i.InternshipRegistration.Company)
.Include(i => i.InternshipRegistration.BranchAddress)
.Include(i => i.InternshipRegistration.Type)
.Include(i => i.InternshipRegistration.Subjects)
.ThenInclude(subject => subject.Subject)
.Include(i => i.InternshipRegistration.Mentor)
.Include(i => i.Report)
.Include(i => i.Documentation)
.Include(i => i.Edition)
.Where(i => i.Id.Equals(internshipId))
.FirstOrDefaultAsync(token);
if (internship == null)
{
return NotFound();
}
return Ok(internship);
}
[HttpGet("{internshipId}/status")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> GetInternshipStatus(long internshipId, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.InternshipRegistration)
.Include(i => i.Report)
.Include(i => i.Documentation)
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
if (internship == null)
{
return NotFound();
}
return new JsonResult(new { Errors = internship.ValidateStatus() });
}
[HttpPut("{internshipId}/grade")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> GradeInternship(long internshipId, [FromBody] float grade, CancellationToken token)
{
var internship = await Context.Internships
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
if (internship == null)
{
return NotFound();
}
internship.Grade = grade;
await Context.SaveChangesAsync(token);
return new JsonResult(new { Errors = internship.ValidateStatus() });
}
[HttpPut("{internshipId}/registration/accept")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> AcceptInternshipRegistration(long internshipId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.InternshipRegistration)
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
if (internship == null)
{
return NotFound();
}
internship.InternshipRegistration.State = DocumentState.Accepted;
internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
await Context.SaveChangesAsync(token);
return Ok();
}
[HttpPut("{internshipId}/registration/reject")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> RejectInternshipRegistration(long internshipId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.InternshipRegistration)
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
if (internship == null)
{
return NotFound();
}
internship.InternshipRegistration.State = DocumentState.Rejected;
internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment;
await Context.SaveChangesAsync(token);
return Ok();
}
}
}

View File

@ -1,32 +1,32 @@
using System.Threading;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Commands;
using InternshipSystem.Api.Security;
using InternshipSystem.Core.Commands;
using InternshipSystem.Api.UseCases;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using InternshipSystem.Api.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("internshipRegistration")]
public class InternshipRegistrationController : ControllerBase
{
private readonly IInternshipService _internshipService;
private readonly InternshipDbContext _context;
public InternshipRegistrationController(IInternshipService internshipService, InternshipDbContext context)
public InternshipRegistrationController(InternshipDbContext dbContext)
{
_internshipService = internshipService;
_context = context;
_context = dbContext;
}
/// <summary>
/// Validate and add filled internship registration form
/// </summary>
/// <param name="updateRegistration">Internship registration data</param>
/// <response code="200">If registration form was successfully added</response>
/// <response code="400">If the provided registration query was malformed</response>
/// <response code="401">This action is only available for authorized student registered for current edition</response>
@ -36,19 +36,50 @@ namespace InternshipSystem.Api.Controllers
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> SubmitRegistrationForm(
[FromBody] UpdateRegistrationForm registrationQuery,
[FromServices] User user,
[FromBody] UpdateRegistrationForm registrationCommand,
[FromServices] User user,
CancellationToken cancellationToken)
{
var edition = await _context.Editions.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var edition = await _context.Editions
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(t => t.InternshipType)
.Include(e => e.AvailableSubjects)
.ThenInclude(t => t.Subject)
.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship = await _context
.Entry(edition)
.Collection(e => e.Internships)
.Query()
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
var internship =
await _context
.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.InternshipRegistration)
.ThenInclude(r => r.BranchAddress)
.Include(i => i.InternshipRegistration)
.ThenInclude(r => r.Company)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Company.Branches)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Type)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Subjects)
.Include(i => i.Documentation)
.Where(i => i.Student.Id == user.PersonNumber)
.FirstAsync(cancellationToken);
var useCase = new UpdateInternshipRegistrationUseCase(_context, internship, edition, user);
try
{
var (status, result) = await useCase.UpdateInternshipRegistration(registrationCommand, cancellationToken);
internship.UpdateInternshipRegistration(registrationQuery);
await _context.SaveChangesAsync(cancellationToken);
return new JsonResult(new {Status = status, Errors = result});
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
}
}
}

View File

@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Repository;
@ -14,30 +14,31 @@ using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("internshipType")]
[Route("internshipTypes")]
public class InternshipTypesController : ControllerBase
{
private InternshipDbContext Context { get; }
public InternshipTypesController(InternshipDbContext context)
{
Context = context;
}
private InternshipDbContext Context { get; }
/// <summary>
/// Get static page
/// Get internship types available for current edition
/// </summary>
/// <returns>List of internship types for edition</returns>
[HttpGet]
/// <returns>List of internship types for current edition</returns>
[HttpGet("current")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult<IList<InternshipType>>> GetInternshipTypesForEdition([FromServices] User user, CancellationToken cancellationToken)
public async Task<ActionResult<IEnumerable<InternshipType>>> GetInternshipTypesForEdition([FromServices] User user, CancellationToken cancellationToken)
{
var edition =
await Context.Editions
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(e => e.InternshipType)
.Where(e => e.Id.Equals(user.EditionId))
.FirstOrDefaultAsync(cancellationToken: cancellationToken);
@ -46,7 +47,125 @@ namespace InternshipSystem.Api.Controllers
return NotFound();
}
return Ok(edition.AvailableInternshipTypes);
return Ok(edition.AvailableInternshipTypes.Select(e => e.InternshipType));
}
/// <summary>
/// Get internship type by id
/// </summary>
/// <returns>Internship type</returns>
/// <response code="200">Internship type returned successfully</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Internship type not found</response>
[HttpGet("{internshipTypeId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult<InternshipType>> GetInternshipType(long internshipTypeId, CancellationToken cancellationToken)
{
return await Context.InternshipTypes.FindAsync(internshipTypeId);
}
/// <summary>
/// Get internship type list
/// </summary>
/// <returns>Internship type</returns>
/// <response code="200">Internship type list returned successfully</response>
/// <response code="401">This action is only available for authorized internship admin</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize]
public async Task<ActionResult<IEnumerable<InternshipType>>> SearchInternshipTypes([FromQuery] InternshipTypeSearchQuery searchQuery, CancellationToken cancellationToken)
{
return await Context.InternshipTypes
.Where(t => string.IsNullOrEmpty(searchQuery.Label) || t.Label.Contains(searchQuery.Label))
.Where(t => string.IsNullOrEmpty(searchQuery.LabelEng) || t.Label.Contains(searchQuery.LabelEng))
.OrderBy(t => t.Label)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(cancellationToken);
}
/// <summary>
/// Add or update internship type, only available for coordinator
/// </summary>
/// <response code="200">Internship type updated successfully</response>
/// <response code="400">Invalid internship type form</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Internship type with selected id do not exist</response>
[HttpPut]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> UpsertInternshipType([FromBody] InternshipTypeFrom internshipTypeFrom, CancellationToken cancellationToken)
{
var validator = new InternshipTypeFrom.Validator();
var validationResult = await validator.ValidateAsync(internshipTypeFrom, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
if (internshipTypeFrom.Id.HasValue)
{
var internshipType = await Context.InternshipTypes.FindAsync(internshipTypeFrom.Id.Value);
if (internshipType == null)
{
return NotFound($"Internship type with id {internshipTypeFrom.Id} not found");
}
internshipType.Label = string.IsNullOrEmpty(internshipTypeFrom.Label) ? internshipType.Label : internshipTypeFrom.Label;
internshipType.LabelEng = string.IsNullOrEmpty(internshipTypeFrom.LabelEng) ? internshipType.LabelEng : internshipTypeFrom.LabelEng;
internshipType.Description = string.IsNullOrEmpty(internshipTypeFrom.Description) ? internshipType.Description : internshipTypeFrom.Description;
internshipType.DescriptionEng = string.IsNullOrEmpty(internshipTypeFrom.DescriptionEng) ? internshipType.DescriptionEng : internshipTypeFrom.DescriptionEng;
}
else
{
var newInternshipType = new InternshipType
{
Label = internshipTypeFrom.Label,
LabelEng = internshipTypeFrom.LabelEng,
Description = internshipTypeFrom.Description,
DescriptionEng = internshipTypeFrom.DescriptionEng,
};
await Context.InternshipTypes.AddAsync(newInternshipType, cancellationToken);
}
await Context.SaveChangesAsync(cancellationToken);
return Ok();
}
/// <summary>
/// Add or update internship type
/// </summary>
/// <response code="200">Internship type deleted successfully</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Internship type with selected id do not exist</response>
[HttpDelete("{internshipTypeId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> DeleteInternshipType(long internshipTypeId, CancellationToken cancellationToken)
{
var internshipTypeToDelete = await Context.InternshipTypes
.FirstOrDefaultAsync(t => t.Id.Equals(internshipTypeId), cancellationToken: cancellationToken);
if (internshipTypeToDelete == null)
{
return NotFound($"Internship type with id: {internshipTypeId} does not exist");
}
Context.InternshipTypes.Remove(internshipTypeToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok($"Internship type with id: {internshipTypeId} deleted successfully");
}
}
}

View File

@ -6,6 +6,7 @@ using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
@ -19,7 +20,7 @@ namespace InternshipSystem.Api.Controllers
{
_context = context;
}
/// <summary>
/// Register student for edition using provided registration code
/// </summary>
@ -35,20 +36,29 @@ namespace InternshipSystem.Api.Controllers
[Authorize]
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode, [FromServices] User user, CancellationToken token)
{
var edition = await _context.Editions.FindAsync(registrationCode, token);
var edition = await _context.Editions
.Include(e => e.Internships)
.ThenInclude(i => i.Student)
.FirstOrDefaultAsync(e => e.Id.Equals(registrationCode), cancellationToken: token);
if (edition == null)
{
return NotFound();
}
var student = await _context.Students.FindAsync(user.PersonNumber, token);
var student = await _context.Students.FindAsync(user.PersonNumber);
try
{
edition.RegisterInternship(student);
await _context.SaveChangesAsync(token);
}
catch (ArgumentException e)
{
return BadRequest(e.Message);
}
edition.RegisterInternship(student);
await _context.SaveChangesAsync(token);
return Ok();
}
}
}

View File

@ -0,0 +1,62 @@
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Security;
using InternshipSystem.Core.ValueObject;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace InternshipSystem.Api.Controllers
{
[Route("internship/report")]
public class ReportController : ControllerBase
{
private readonly InternshipDbContext _context;
public ReportController(InternshipDbContext context)
{
_context = context;
}
[HttpPost]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> PostReport([FromBody] JObject reportValue, [FromServices] User user, CancellationToken ct)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Report)
.Include(i => i.Documentation)
.SingleAsync(i => i.Student.Id == user.PersonNumber, ct);
internship.Report.UpdateReport(reportValue.ToString(Formatting.None));
internship.AddNewDocument("", DocumentType.InternshipEvaluation);
await _context.SaveChangesAsync(ct);
return Ok();
}
[HttpGet]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> GetReport([FromServices] User user, CancellationToken ct)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Report)
.SingleAsync(i => i.Student.Id == user.PersonNumber, ct);
return Ok(JsonConvert.DeserializeObject(internship.Report.Value));
}
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using InternshipSystem.Api.Queries.SearchQuery;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[Route("management/report")]
public class ReportFieldsController : ControllerBase
{
private readonly InternshipDbContext _context;
private readonly IMapper _mapper;
public ReportFieldsController(InternshipDbContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}
[HttpGet("fields")]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<IEnumerable<ReportField>> GetFields(FieldSearchQuery searchQuery, CancellationToken ct) =>
await _context.ReportFields
.Where(c => c.Label.ToLower().Contains(searchQuery.Label.ToLower()))
.OrderBy(o => o.Label)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(ct);
[HttpPost("fields")]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> CreateField([FromBody] FieldCreateRequest request, CancellationToken ct)
{
ReportField field;
switch (request.FieldType)
{
case FieldType.LongText:
case FieldType.ShortText:
field = new ReportField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType);
break;
case FieldType.Select:
case FieldType.Radial:
case FieldType.Checkbox:
field = new ReportChoiceField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType, request.Choices);
break;
default:
return BadRequest("Unknown field type");
}
try
{
await _context.ReportFields.AddAsync(field, ct);
await _context.SaveChangesAsync(ct);
}
catch (Exception e)
{
return BadRequest("Failed");
}
return Ok();
}
}
public class FieldSearchQuery : SearchQuery
{
public string Label { get; set; } = "";
}
public class FieldCreateRequest
{
public long? Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public FieldType FieldType { get; set; }
public string[] Choices { get; set; }
}
}

View File

@ -2,8 +2,10 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@ -19,11 +21,12 @@ namespace InternshipSystem.Api.Controllers
Context = context;
}
private InternshipDbContext Context { get; }
/// <summary>
/// Get all static pages
/// Get all static pages, only available for coordinator
/// </summary>
/// <returns>List of static pages with titles and content</returns>
/// <response code="200">Static pages list returned successfully</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<IList<StaticPage>>> GetStaticPages(CancellationToken cancellationToken) =>
@ -31,10 +34,12 @@ namespace InternshipSystem.Api.Controllers
.ToListAsync(cancellationToken);
/// <summary>
/// Get static page
/// Get static page, only available for coordinator
/// </summary>
/// <param name="accessName">Name of page</param>
/// <returns>Static page title and content</returns>
/// <response code="200">Static page returned successfully</response>
/// <response code="404">Static page with given access name do not exist</response>
[HttpGet("{accessName}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@ -52,5 +57,107 @@ namespace InternshipSystem.Api.Controllers
return Ok(page);
}
/// <summary>
/// Add or update static page, only available for coordinator
/// </summary>
/// <response code="200">Static page updated successfully</response>
/// <response code="400">Static page form is not valid</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Static page with given id do not exist</response>
[HttpPut]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> UpdateStaticPage([FromBody] StaticPageForm staticPageForm, CancellationToken cancellationToken)
{
var validator = new StaticPageForm.Validator();
var validationResult = await validator.ValidateAsync(staticPageForm, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
if (staticPageForm.Id.HasValue)
{
var pageToUpdate = await Context.StaticPages.FindAsync(staticPageForm.Id);
if (pageToUpdate == null)
{
return NotFound($"Static page with id: {staticPageForm.Id} does not exist");
}
if (!string.IsNullOrEmpty(staticPageForm.AccessName))
{
var pageWithSameAccessName = await Context.StaticPages
.FirstOrDefaultAsync(sp => sp.AccessName.ToLower().Trim().Equals(staticPageForm.AccessName.ToLower().Trim()), cancellationToken: cancellationToken);
if (pageWithSameAccessName != null && !pageWithSameAccessName.Id.Equals(pageToUpdate.Id))
{
return BadRequest($"Static page with access name: {staticPageForm.AccessName} already exist");
}
}
pageToUpdate.AccessName = string.IsNullOrEmpty(staticPageForm.AccessName) ? pageToUpdate.AccessName : staticPageForm.AccessName;
pageToUpdate.Title = string.IsNullOrEmpty(staticPageForm.Title) ? pageToUpdate.Title : staticPageForm.Title;
pageToUpdate.TitleEng = string.IsNullOrEmpty(staticPageForm.TitleEng) ? pageToUpdate.TitleEng : staticPageForm.TitleEng;
pageToUpdate.Content = string.IsNullOrEmpty(staticPageForm.Content) ? pageToUpdate.Content : staticPageForm.Content;
pageToUpdate.ContentEng = string.IsNullOrEmpty(staticPageForm.ContentEng) ? pageToUpdate.ContentEng : staticPageForm.ContentEng;
}
else
{
var pageWithSameAccessName = await Context.StaticPages
.FirstOrDefaultAsync(sp => sp.AccessName.ToLower().Trim().Equals(staticPageForm.AccessName.ToLower().Trim()), cancellationToken: cancellationToken);
if (pageWithSameAccessName != null)
{
return BadRequest($"Static page with access name: {staticPageForm.AccessName} already exist");
}
var newStaticPage = new StaticPage
{
AccessName = staticPageForm.AccessName.ToLower().Trim(),
Title = staticPageForm.Title,
TitleEng = staticPageForm.TitleEng,
Content = staticPageForm.Content,
ContentEng = staticPageForm.ContentEng,
};
await Context.StaticPages.AddAsync(newStaticPage, cancellationToken);
}
await Context.SaveChangesAsync(cancellationToken);
return Ok($"Static page updated successfully");
}
/// <summary>
/// Delete static page, only available for coordinator
/// </summary>
/// <response code="200">Static page deleted successfully</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Static page with given access name do not exist</response>
[HttpDelete("{accessName}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> DeleteStaticPage(string accessName, CancellationToken cancellationToken)
{
var pageToDelete = await Context.StaticPages
.FirstOrDefaultAsync(sp => sp.AccessName.ToLower().Trim().Equals(accessName.ToLower().Trim()), cancellationToken: cancellationToken);
if (pageToDelete == null)
{
return NotFound($"Static page with access name: {accessName} does not exist");
}
Context.StaticPages.Remove(pageToDelete);
await Context.SaveChangesAsync(cancellationToken);
return Ok($"Static page with access name: {accessName} deleted successfully");
}
}
}

View File

@ -0,0 +1,143 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[Route("students")]
[ApiController]
public class StudentsController : ControllerBase
{
private readonly InternshipDbContext _context;
public StudentsController(InternshipDbContext context)
{
_context = context;
}
/// <summary>
/// Get current student personal data
/// </summary>
/// <returns>Current student data</returns>
/// <response code="200">Current student data returned successfully</response>
/// <response code="401">his action is only available for authorized student</response>
[HttpGet("current")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize]
public async Task<ActionResult<Student>> GetCurrentStudentData([FromServices] User user, CancellationToken cancellationToken)
{
return await _context.Students.FindAsync(user.PersonNumber);
}
/// <summary>
/// Update current student personal data
/// </summary>
/// <response code="200">Current student data updated successfully</response>
/// <response code="401">his action is only available for authorized student</response>
[HttpPut("current")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize]
public async Task<ActionResult> UpdateCurrentStudentData([FromBody] CurrentStudentForm studentNewData, [FromServices] User user, CancellationToken cancellationToken)
{
var currentStudent = await _context.Students.FindAsync(user.PersonNumber);
currentStudent.AlbumNumber = studentNewData.AlbumNumber ?? currentStudent.AlbumNumber;
currentStudent.FirstName = string.IsNullOrEmpty(studentNewData.FirstName) ? currentStudent.FirstName : studentNewData.FirstName;
currentStudent.LastName = string.IsNullOrEmpty(studentNewData.LastName) ? currentStudent.LastName : studentNewData.LastName;
currentStudent.Email = string.IsNullOrEmpty(studentNewData.Email) ? currentStudent.Email : studentNewData.Email;
currentStudent.Course = string.IsNullOrEmpty(studentNewData.Course) ? currentStudent.Course : studentNewData.Course;
currentStudent.Semester = studentNewData.Semester ?? currentStudent.Semester;
await _context.SaveChangesAsync(cancellationToken);
return Ok();
}
/// <summary>
/// Get student personal data, only available for coordinator
/// </summary>
/// <returns>Student personal data</returns>
/// <response code="200">Student data returned successfully</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Student with given id do not exist</response>
[HttpGet("{studentPersonNumber}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult<Student>> GetStudentByPersonNumber(long studentPersonNumber, CancellationToken cancellationToken) =>
await _context.Students.FindAsync(studentPersonNumber);
/// <summary>
/// Search students personal data, only available for coordinator
/// </summary>
/// <returns>List of students personal data</returns>
/// <response code="200">List of student data</response>
/// <response code="401">This action is only available for authorized internship admin</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize]
public async Task<ActionResult<IReadOnlyCollection<Student>>> SearchStudents([FromQuery] StudentSearchQuery searchQuery, CancellationToken cancellationToken) =>
await _context.Students
.Where(s => !searchQuery.AlbumNumber.HasValue || s.AlbumNumber.Equals(searchQuery.AlbumNumber))
.Where(s => string.IsNullOrEmpty(searchQuery.FirstName) || s.FirstName.ToLower().Contains(searchQuery.FirstName.ToLower()))
.Where(s => string.IsNullOrEmpty(searchQuery.LastName) || s.LastName.ToLower().Contains(searchQuery.LastName.ToLower()))
.OrderBy(s => s.AlbumNumber)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(cancellationToken);
/// <summary>
/// Updates student personal data, only available for coordinator
/// </summary>
/// <response code="200">Student data updated successfully</response>
/// <response code="401">This action is only available for authorized internship admin</response>
/// <response code="404">Student with given id do not exist</response>
[HttpPut("{studentId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize]
public async Task<ActionResult> UpdateStudentData(long studentId, [FromBody] StudentForm studentNewData, CancellationToken cancellationToken)
{
var validator = new StudentForm.Validator();
var validationResult = await validator.ValidateAsync(studentNewData, cancellationToken);
if (!validationResult.IsValid)
{
return BadRequest(validationResult.ToString());
}
var currentStudent = await _context.Students.FindAsync(studentId);
if (currentStudent == null)
{
return NotFound();
}
currentStudent.AlbumNumber = studentNewData.AlbumNumber ?? currentStudent.AlbumNumber;
currentStudent.FirstName = string.IsNullOrEmpty(studentNewData.FirstName) ? currentStudent.FirstName : studentNewData.FirstName;
currentStudent.LastName = string.IsNullOrEmpty(studentNewData.LastName) ? currentStudent.LastName : studentNewData.LastName;
currentStudent.Email = string.IsNullOrEmpty(studentNewData.Email) ? currentStudent.Email : studentNewData.Email;
currentStudent.Course = string.IsNullOrEmpty(studentNewData.Course) ? currentStudent.Course : studentNewData.Course;
currentStudent.Semester = studentNewData.Semester ?? currentStudent.Semester;
await _context.SaveChangesAsync(cancellationToken);
return Ok();
}
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace InternshipSystem.Api.Converters
{
public class StringArrayConverter<TItem> : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var token = JToken.Load(reader);
if (token.Type == JTokenType.Array)
{
return token.ToObject<List<TItem>>();
}
return new List<TItem>
{
token.ToObject<TItem>()
};
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(List<TItem>);
}
public override bool CanWrite => false;
}
}

View File

@ -0,0 +1,50 @@
using System;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.DependencyInjection;
namespace InternshipSystem.Api.Extensions
{
public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder UseMigration(this IApplicationBuilder app)
{
bool done = false;
while (!done)
{
try
{
using var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope();
using var context = serviceScope.ServiceProvider.GetService<InternshipDbContext>();
context.Database.Migrate();
done = true;
}
catch (Exception)
{
// ignored
}
}
return app;
}
public static IApplicationBuilder UseDefaultData(this IApplicationBuilder app, bool useDefaultData)
{
using var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope();
using var context = serviceScope.ServiceProvider.GetService<InternshipDbContext>();
var filler = serviceScope.ServiceProvider.GetService<DatabaseFiller>();
context.Database.Migrate();
if (useDefaultData && !context.Editions.Any())
{
filler.FillAll().Wait();
}
return app;
}
}
}

View File

@ -1,11 +1,13 @@
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Options;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using JsonConverter = System.Text.Json.Serialization.JsonConverter;
namespace InternshipSystem.Api.Controllers
{
@ -39,9 +41,9 @@ namespace InternshipSystem.Api.Controllers
};
var response = await _client.SendAsync(request, cancellationToken);
await using var stream = await response.Content.ReadAsStreamAsync();
var content = await response.Content.ReadAsStringAsync();
var value = await JsonSerializer.DeserializeAsync<Dictionary<string, object>>(stream);
var value = JsonConvert.DeserializeObject<Dictionary<string, object>>(content);
return value["access_token"].ToString();
}
@ -60,15 +62,10 @@ namespace InternshipSystem.Api.Controllers
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
var response = await _client.SendAsync(request, cancellationToken);
await using var stream = await response.Content.ReadAsStreamAsync();
var result = await JsonSerializer.DeserializeAsync<CasUserProfile>(
stream,
new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
}, cancellationToken);
var content = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<CasUserProfile>(content);
return result.Attributes;
}
}

View File

@ -12,11 +12,13 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="FluentValidation" Version="9.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.6.3" />
<PackageReference Include="IdentityServer4" Version="3.1.4" />
</ItemGroup>

View File

@ -1,14 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Events;
using Serilog.Formatting.Compact;
namespace InternshipSystem.Api
{

View File

@ -17,18 +17,18 @@ namespace InternshipSystem.Api.Queries
{
RuleFor(b => b.Id).NotNull()
.When(c =>
!string.IsNullOrEmpty(c.Country) || !string.IsNullOrEmpty(c.City) ||
!string.IsNullOrEmpty(c.PostalCode) || !string.IsNullOrEmpty(c.Street) ||
!string.IsNullOrEmpty(c.Building));
RuleFor(b => b.Country).NotNull()
string.IsNullOrEmpty(c.Country) || string.IsNullOrEmpty(c.City) ||
string.IsNullOrEmpty(c.PostalCode) || string.IsNullOrEmpty(c.Street) ||
string.IsNullOrEmpty(c.Building));
RuleFor(b => b.Country).NotEmpty()
.When(b => !b.Id.HasValue);
RuleFor(b => b.City).NotNull()
RuleFor(b => b.City).NotEmpty()
.When(b => !b.Id.HasValue);
RuleFor(b => b.PostalCode).NotNull()
RuleFor(b => b.PostalCode).NotEmpty()
.When(b => !b.Id.HasValue);
RuleFor(b => b.Street).NotNull()
RuleFor(b => b.Street).NotEmpty()
.When(b => !b.Id.HasValue);
RuleFor(b => b.Building).NotNull()
RuleFor(b => b.Building).NotEmpty()
.When(b => !b.Id.HasValue);
}
}

View File

@ -13,7 +13,7 @@ namespace InternshipSystem.Api.Queries
public Validator()
{
RuleFor(c => c.Id).NotNull()
.When(c => !string.IsNullOrEmpty(c.Nip) || !string.IsNullOrEmpty(c.Name));
.When(c => string.IsNullOrEmpty(c.Nip) || string.IsNullOrEmpty(c.Name));
RuleFor(c => c.Nip).NotEmpty()
.When(c => !c.Id.HasValue);
RuleFor(c => c.Name).NotEmpty()

View File

@ -0,0 +1,23 @@
using FluentValidation;
namespace InternshipSystem.Api.Queries
{
public class CourseForm
{
public long? Id { get; set; }
public string Name { get; set; }
public string NameEng { get; set; }
public class Validator : AbstractValidator<CourseForm>
{
public Validator()
{
RuleFor(c => c.Id).NotNull()
.When(c => string.IsNullOrWhiteSpace(c.Name));
RuleFor(c => c.Name).NotEmpty()
.When(c => !c.Id.HasValue);
}
}
}
}

View File

@ -0,0 +1,12 @@
namespace InternshipSystem.Api.Queries
{
public class CurrentStudentForm
{
public int? AlbumNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Course { get; set; }
public int? Semester { get; set; }
}
}

View File

@ -1,22 +1,16 @@
using FluentValidation;
using InternshipSystem.Core.ValueObject;
using Microsoft.AspNetCore.Http;
namespace InternshipSystem.Api.Queries
{
public class DocumentPublishRequest
{
public long? Id { get; set; }
public string Description { get; set; }
public byte[] Scan { get; set; }
public DocumentType Type { get; set; }
public class Validator : AbstractValidator<DocumentPublishRequest>
{
public Validator()
{
RuleFor(document => document.Scan).NotEmpty();
RuleFor(document => document.Type).NotEmpty();
}
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Api.Queries
{
public class EditionForm
{
public Guid? Id { get; set; }
public DateTime? EditionStart { get; set; }
public DateTime? EditionFinish { get; set; }
public DateTime? ReportingStart { get; set; }
public Course Course { get; set; }
public List<long> AvailableSubjectsIds { get; set; } = new List<long>();
public List<long> AvailableInternshipTypesIds { get; set; } = new List<long>();
public List<long> ReportSchema { get; set; } = new List<long>();
public class Validator : AbstractValidator<EditionForm>
{
public Validator()
{
RuleFor(e => e.Id).NotNull()
.When(e => !e.EditionStart.HasValue || !e.EditionFinish.HasValue
|| !e.ReportingStart.HasValue || e.Course == null);
RuleFor(e => e.EditionStart).NotEmpty()
.When(e => !e.Id.HasValue);
RuleFor(e => e.EditionFinish).NotEmpty()
.When(e => !e.Id.HasValue);
RuleFor(e => e.ReportingStart).NotEmpty()
.When(e => !e.Id.HasValue);
RuleFor(e => e.Course).NotNull()
.When(e => !e.Id.HasValue);
}
}
}
}

View File

@ -0,0 +1,27 @@
using FluentValidation;
namespace InternshipSystem.Api.Queries
{
public class InternshipTypeFrom
{
public long? Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public class Validator : AbstractValidator<InternshipTypeFrom>
{
public Validator()
{
RuleFor(t => t.Id).NotNull()
.When(t =>
string.IsNullOrEmpty(t.Label) || string.IsNullOrEmpty(t.LabelEng));
RuleFor(t => t.Label).NotEmpty()
.When(t => !t.Id.HasValue);
RuleFor(t => t.LabelEng).NotEmpty()
.When(t => !t.Id.HasValue);
}
}
}
}

View File

@ -0,0 +1,9 @@
using InternshipSystem.Api.Queries.SearchQuery;
namespace InternshipSystem.Api.Controllers
{
public class BranchOfficeSearchQuery : SearchQuery
{
public string City { get; set; } = "";
}
}

View File

@ -0,0 +1,10 @@
namespace InternshipSystem.Api.Queries.SearchQuery
{
public class CompanySearchQuery : SearchQuery
{
/// <summary>
/// Value against which collection will be queried
/// </summary>
public string Name { get; set; } = "";
}
}

View File

@ -0,0 +1,7 @@
namespace InternshipSystem.Api.Queries.SearchQuery
{
public class EditionSearchQuery : SearchQuery
{
public long? Course { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using InternshipSystem.Core;
namespace InternshipSystem.Api.Queries.SearchQuery
{
public class InternshipSearchQuery : SearchQuery
{
public Guid? EditionId { get; set; } = null;
public DocumentState? InternshipState { get; set; } = null;
public DocumentState? ReportState { get; set; }
public int? StudentAlbumNumber { get; set; } = null;
public string StudentFirstName { get; set; } = "";
public string StudentLastName { get; set; } = "";
/// <summary>
/// SortValue: Date, InternshipState
/// </summary>
public string OrderByField { get; set; } = "";
public SortOrder SortOrder { get; set; } = SortOrder.None;
public DocumentState? DocumentWithState { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using InternshipSystem.Api.Queries.SearchQuery;
namespace InternshipSystem.Api.Controllers
{
public class InternshipTypeSearchQuery : SearchQuery
{
public string Label { get; set; } = "";
public string LabelEng { get; set; } = "";
}
}

View File

@ -1,12 +1,7 @@
namespace InternshipSystem.Api.Queries
namespace InternshipSystem.Api.Queries.SearchQuery
{
public class SearchQuery
{
/// <summary>
/// Value against which collection will be queried
/// </summary>
public string Query { get; set; } = "";
/// <summary>
/// Which part of the collections to retrieve
/// </summary>

View File

@ -0,0 +1,9 @@
namespace InternshipSystem.Api.Queries.SearchQuery
{
public enum SortOrder
{
Asc,
Desc,
None
}
}

View File

@ -0,0 +1,11 @@
using InternshipSystem.Api.Queries.SearchQuery;
namespace InternshipSystem.Api.Controllers
{
public class StudentSearchQuery : SearchQuery
{
public int? AlbumNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using FluentValidation;
namespace InternshipSystem.Api.Queries
{
public class StaticPageForm
{
public long? Id { get; set; }
public string AccessName { get; set; }
public string Title { get; set; }
public string TitleEng { get; set; }
public string Content { get; set; }
public string ContentEng { get; set; }
public class Validator : AbstractValidator<StaticPageForm>
{
public Validator()
{
RuleFor(sp => sp.Id).NotNull()
.When(sp =>
string.IsNullOrEmpty(sp.AccessName) || string.IsNullOrEmpty(sp.Title) ||
string.IsNullOrEmpty(sp.TitleEng) || string.IsNullOrEmpty(sp.Content) ||
string.IsNullOrEmpty(sp.ContentEng));
RuleFor(sp => sp.AccessName).NotEmpty()
.When(sp => !sp.Id.HasValue);
RuleFor(sp => sp.Title).NotEmpty()
.When(sp => !sp.Id.HasValue);
RuleFor(sp => sp.TitleEng).NotEmpty()
.When(sp => !sp.Id.HasValue);
RuleFor(sp => sp.Content).NotEmpty()
.When(sp => !sp.Id.HasValue);
RuleFor(sp => sp.ContentEng).NotEmpty()
.When(sp => !sp.Id.HasValue);
}
}
}
}

View File

@ -0,0 +1,21 @@
using FluentValidation;
namespace InternshipSystem.Api.Queries
{
public class StudentForm
{
public int? AlbumNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Course { get; set; }
public int? Semester { get; set; }
public class Validator : AbstractValidator<StudentForm>
{
public Validator()
{
}
}
}
}

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using InternshipSystem.Api.Converters;
using Newtonsoft.Json;
namespace InternshipSystem.Api.Controllers
{
@ -7,8 +9,12 @@ namespace InternshipSystem.Api.Controllers
public string AlbumNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[JsonConverter(typeof(StringArrayConverter<string>))]
public List<string> Mail { get; set; }
public string PersonNumber { get; set; }
[JsonConverter(typeof(StringArrayConverter<string>))]
public List<string> Pg_Cui_Portalroles { get; set; }
}
}

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -8,6 +10,8 @@ namespace InternshipSystem.Api.Result
public class EditionConfigurationResult
{
public List<InternshipSubject> AvailableSubjects { get; set; }
public List<ReportField> ReportSchema { get; set; }
public Course Course { get; set; }
public DateTime EditionStart { get; set; }
public DateTime EditionFinish { get; set; }
public DateTime ReportingStart { get; set; }

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Api.Result
{
public class EditionDetailsResult
{
public Guid Id { get; set; }
public DateTime EditionStart { get; set; }
public DateTime EditionFinish { get; set; }
public DateTime ReportingStart { get; set; }
public Course Course { get; set; }
public List<InternshipSubject> AvailableSubjects { get; set; }
public List<InternshipType> AvailableInternshipTypes { get; set; }
public List<ReportField> ReportSchema { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
namespace InternshipSystem.Api.Result
{
public class EditionManagementResult
{
public Guid Id { get; set; }
public DateTime EditionStart { get; set; }
public DateTime EditionFinish { get; set; }
public DateTime ReportingStart { get; set; }
public Course Course { get; set; }
}
}

View File

@ -2,7 +2,7 @@
namespace InternshipSystem.Api.Result
{
public struct EditionResult
public class EditionResult
{
public Guid Id { get; set; }
public DateTime EditionStart { get; set; }

View File

@ -3,5 +3,6 @@
public static class Policies
{
public const string RegisteredOnly = "RegisteredForEditionOnly";
public const string IsOverseer = "IsOverseer";
}
}

View File

@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.Linq;
namespace InternshipSystem.Api.Service
{
public class FileValidator
{
private readonly List<(string Mime, byte[] Signature)> validFileTypes;
public FileValidator()
{
validFileTypes = new List<(string, byte[])> {
("application/pdf", new byte[] { 0x25, 0x50, 0x44, 0x46 }),
("image/jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xDB }),
("image/jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 }),
("image/jpeg", new byte[] { 0xFF, 0xD8, 0xFF, 0xE1 })
};
}
public bool IsValidFile(byte[] scan)
{
return IsFileValidType(scan);
}
private bool IsFileValidType(byte[] scan)
{
return GetFileMime(scan) != null;
}
public string GetFileMime(byte[] scan)
{
var header = scan[..4];
return validFileTypes.FirstOrDefault(sig => sig.Signature.SequenceEqual(header)).Mime;
}
}
}

View File

@ -1,16 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using Microsoft.AspNetCore.Mvc;
namespace InternshipSystem.Api.Services
{
public interface IInternshipService
{
Task<ActionResult> SubmitRegistration(RegistrationFormQuery registrationQuery, long personNumber,
CancellationToken cancellationToken);
Task<ActionResult> AddDocumentToInternship(DocumentPublishRequest documentRequest, long personNumber,
CancellationToken cancellationToken);
}
}

View File

@ -1,114 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using InternshipSystem.Api.Queries;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Services
{
public class InternshipService : IInternshipService
{
private readonly InternshipDbContext _context;
private IMapper Mapper { get; }
public InternshipService(InternshipDbContext context, IMapper mapper)
{
_context = context;
Mapper = mapper;
}
public async Task<ActionResult> SubmitRegistration(RegistrationFormQuery registrationQuery, long personNumber,
CancellationToken cancellationToken)
{
var edition = await _context.Editions.FindAsync(personNumber);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.SingleAsync(i => i.Student.Id == personNumber, cancellationToken);
var internshipRegistration = internship.InternshipRegistration;
if (registrationQuery.Company != null)
{
var company = registrationQuery.Company.Id.HasValue
? await _context.Companies.SingleAsync(c => c.Id == registrationQuery.Company.Id,
cancellationToken: cancellationToken)
: Company.CreateCompany(registrationQuery.Company.Nip, registrationQuery.Company.Name);
internshipRegistration.UpdateCompany(company);
}
var officeForm = registrationQuery.BranchOffice;
if (officeForm != null)
{
BranchOffice branch;
if (officeForm.Id.HasValue)
{
branch = await _context.Entry(internshipRegistration.Company)
.Collection(c => c.Branches)
.Query()
.SingleAsync(o => o.Id == officeForm.Id, cancellationToken: cancellationToken);
}
else
{
branch = BranchOffice.CreateBranch(officeForm.Country, officeForm.City, officeForm.PostalCode,
officeForm.Street, officeForm.Building);
internshipRegistration.Company.AddBranchOffice(branch);
}
internshipRegistration.UpdateBranch(branch);
}
internshipRegistration.Start = registrationQuery.Start ?? internshipRegistration.Start;
internshipRegistration.End = registrationQuery.End ?? internshipRegistration.End;
if (registrationQuery.Type != null && edition.IsInternshipTypeAllowed(registrationQuery.Type))
{
return new BadRequestObjectResult("Edition doesn't have this type of employment in available employments type");
}
internshipRegistration.Type = registrationQuery.Type ?? internshipRegistration.Type;
await _context.SaveChangesAsync(cancellationToken);
return new OkResult();
}
public async Task<ActionResult> AddDocumentToInternship(DocumentPublishRequest documentRequest, long personNumber,
CancellationToken cancellationToken)
{
var edition = await _context.Editions.FindAsync(personNumber);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.SingleAsync(i => i.Student.Id == personNumber, cancellationToken);
var document = Mapper.Map<Document>(documentRequest);
if (documentRequest.Id.HasValue)
{
try
{
internship.UpdateDocument(document);
}
catch (InvalidOperationException)
{
return new NotFoundResult();
}
}
else
{
internship.AddNewDocument(document);
}
await _context.SaveChangesAsync(cancellationToken);
return new OkResult();
}
}
}

View File

@ -1,7 +0,0 @@
namespace InternshipSystem.Api.Services
{
public class UserService
{
}
}

View File

@ -7,8 +7,7 @@ using InternshipSystem.Api.Extensions;
using InternshipSystem.Api.ModelBinders;
using InternshipSystem.Api.Options;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.Services;
using InternshipSystem.Core;
using InternshipSystem.Api.Service;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@ -17,6 +16,8 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace InternshipSystem.Api
{
@ -37,6 +38,8 @@ namespace InternshipSystem.Api
.AddAuthorization(o =>
{
o.AddPolicy(Policies.RegisteredOnly, policy => policy.RequireClaim("Edition"));
//TODO: change to claim for InternshipRepresentative
o.AddPolicy(Policies.IsOverseer, policy => policy.RequireClaim("PersonNumber"));
})
.AddHttpClient<GutCasClient>();
@ -44,7 +47,7 @@ namespace InternshipSystem.Api
.AddDbContext<InternshipDbContext>(o =>
o.UseNpgsql(Configuration.GetConnectionString("InternshipDatabase")))
.AddScoped<DatabaseFiller>()
.AddScoped<IInternshipService, InternshipService>()
.AddScoped<FileValidator>()
.AddScoped<JwtTokenService>()
.AddAutoMapper(cfg => cfg.AddProfile<ApiProfile>());
@ -56,14 +59,24 @@ namespace InternshipSystem.Api
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
options.IncludeXmlComments(xmlPath);
})
.AddControllers(o => { o.ModelBinderProviders.Insert(0, new UserBinderProvider()); });
.AddSwaggerGenNewtonsoftSupport()
.AddControllers(o => { o.ModelBinderProviders.Insert(0, new UserBinderProvider()); })
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseMigration();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app
.UseDefaultData("true".Equals(Environment.GetEnvironmentVariable("FILLER__USE_DEFAULT_DATA")))
.UseDeveloperExceptionPage();
}
app

View File

@ -0,0 +1,189 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using IdentityServer4.Extensions;
using InternshipSystem.Api.Commands;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
using InternshipSystem.Core.ValueObject;
using InternshipSystem.Repository;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.UseCases
{
public class UpdateInternshipRegistrationUseCase
{
private readonly InternshipDbContext _dbContext;
private readonly Internship _internship;
private readonly Edition _edition;
private readonly User _user;
private readonly InternshipRegistration subjectRegistration;
public UpdateInternshipRegistrationUseCase(InternshipDbContext dbContext,
Internship internship, Edition edition, User user)
{
_dbContext = dbContext;
_internship = internship;
_edition = edition;
_user = user;
_internship = internship;
subjectRegistration = internship.InternshipRegistration;
}
public async Task<(DocumentState State, IEnumerable<ErrorDescription>)> UpdateInternshipRegistration(
UpdateRegistrationForm registrationCommand,
CancellationToken cancellationToken)
{
UpdateTimeFrame(registrationCommand);
subjectRegistration.DeclaredHours = registrationCommand.Hours ?? subjectRegistration.DeclaredHours;
if (registrationCommand.Type.HasValue)
{
UpdateInternshipType(registrationCommand.Type.Value);
}
if (registrationCommand.Mentor.HasValue)
{
UpdateMentor(registrationCommand.Mentor.Value);
}
if (!registrationCommand.Subjects.IsNullOrEmpty())
{
UpdateSubjects(registrationCommand.Subjects);
}
if (registrationCommand.Company.HasValue)
{
await UpdateCompanyAndBranch(registrationCommand.Company.Value, cancellationToken);
}
return subjectRegistration.ValidateStatus(_edition);
}
private void UpdateTimeFrame(UpdateRegistrationForm registrationCommand)
{
subjectRegistration.Start = registrationCommand.Start ?? subjectRegistration.Start;
subjectRegistration.End = registrationCommand.End ?? subjectRegistration.End;
if (!_edition.IsDateDuringEdition(subjectRegistration.Start, subjectRegistration.End))
{
_internship.AddNewDocument("", DocumentType.OutsideTermApproval);
}
else
{
_internship.RemoveDocument(DocumentType.OutsideTermApproval);
}
}
private void UpdateInternshipType(long typeId)
{
var editionInternshipType = _edition.AvailableInternshipTypes.FirstOrDefault(i => i.InternshipTypeId == typeId);
if (editionInternshipType?.InternshipType.RequireDeansApproval == true)
{
_internship.AddNewDocument("", DocumentType.InternshipTypeApproval);
}
else
{
_internship.RemoveDocument(DocumentType.InternshipTypeApproval);
}
if (editionInternshipType?.InternshipType.RequireInsurance == true)
{
_internship.AddNewDocument("", DocumentType.NnwInsurance);
}
else
{
_internship.RemoveDocument(DocumentType.NnwInsurance);
}
subjectRegistration.Type = editionInternshipType?.InternshipType ?? subjectRegistration.Type;
}
private async Task UpdateCompanyAndBranch(UpdateCompany companyUpdate, CancellationToken cancellationToken)
{
var company = subjectRegistration.Company;
if (companyUpdate.Id.HasValue)
{
company = await _dbContext.Companies
.Include(c => c.Branches)
.FirstAsync(c => c.Id == companyUpdate.Id.Value, cancellationToken);
}
else if (companyUpdate.IsCustomUpdate)
{
company = await _dbContext.Companies
.Include(c => c.Branches)
.SingleOrDefaultAsync(c => c.Provider == _user.PersonNumber, cancellationToken)
?? Company.CreateCompany(companyUpdate.Nip, companyUpdate.Name, _user.PersonNumber);
company.Name = companyUpdate.Name ?? company.Name;
company.Nip = companyUpdate.Nip ?? company.Nip;
subjectRegistration.BranchAddress = null;
}
if (companyUpdate.BranchOffice.HasValue)
{
var branchUpdate = companyUpdate.BranchOffice.Value;
var branch = subjectRegistration.BranchAddress;
if (branchUpdate.Id.HasValue)
{
branch = company.Branches.First(b => b.Id == branchUpdate.Id.Value);
}
else if (branchUpdate.IsCustomUpdate)
{
branch = company.Branches.FirstOrDefault(b => b.Provider == _user.PersonNumber);
if (branch == null)
{
branch = BranchOffice.CreateBranch(branchUpdate.Country, branchUpdate.City, branchUpdate.PostalCode,
branchUpdate.Street, branchUpdate.Building, _user.PersonNumber);
company.AddBranchOffice(branch);
}
branch.Address.Country = branchUpdate.Country ?? branch.Address.Country;
branch.Address.City = branchUpdate.City ?? branch.Address.City;
branch.Address.PostalCode = branchUpdate.PostalCode ?? branch.Address.PostalCode;
branch.Address.Street = branchUpdate.Country ?? branch.Address.Street;
branch.Address.Building = branchUpdate.Building ?? branch.Address.Building;
}
subjectRegistration.BranchAddress = branch;
}
subjectRegistration.Company = company;
}
private void UpdateSubjects(IEnumerable<long> subjects)
{
if (!_edition.AreSubjectsAvailable(subjects))
{
throw new ArgumentException("subjects chosen are not available in this edition");
}
subjectRegistration.Subjects =
subjects
.Select(i => new ProgramSubject
{
Registration = subjectRegistration,
InternshipSubjectId = i
})
.ToList();
}
private void UpdateMentor(UpdateMentor mentorUpdate)
{
subjectRegistration.Mentor ??= new Mentor();
subjectRegistration.Mentor.UpdateInformation(mentorUpdate.FirstName, mentorUpdate.LastName, mentorUpdate.Email, mentorUpdate.PhoneNumber);
}
}
}

View File

@ -1,31 +1,48 @@
namespace InternshipSystem.Core
using FluentValidation;
using FluentValidation.Validators;
namespace InternshipSystem.Core
{
public class BranchOffice
{
public BranchOffice()
{
}
private BranchOffice(BranchAddress address)
private BranchOffice(BranchAddress address, long provider)
{
Address = address;
Provider = provider;
}
public long Id { get; set; }
public BranchAddress Address { get; set; }
public static BranchOffice CreateBranch(string country, string city, string postalCode, string street, string building)
public long Provider { get; set; }
public static BranchOffice CreateBranch(string country, string city, string postalCode, string street,
string building, long provider = 0)
{
var address = new BranchAddress
{
Building = building,
Building = building,
City = city,
Country = country,
Street = street,
PostalCode = postalCode
};
return new BranchOffice(address);
return new BranchOffice(address, provider);
}
public class Validator : AbstractValidator<BranchOffice>
{
public Validator()
{
RuleFor(x => x.Address)
.SetValidator(new BranchAddress.Validator());
}
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using InternshipSystem.Core.Commands;
using FluentValidation;
using FluentValidation.Validators;
namespace InternshipSystem.Core
{
@ -11,25 +12,33 @@ namespace InternshipSystem.Core
public string Name { get; set; }
public List<BranchOffice> Branches { get; set; }
public static Company CreateCompany(string nip, string name) =>
public long Provider { get; set; }
public static Company CreateCompany(string nip, string name, long provider = 0) =>
new Company
{
Nip = nip,
Name = name
Name = name,
Provider = provider,
Branches = new List<BranchOffice>()
};
public void AddBranchAddress(BranchAddress branch)
{
}
public void AddBranchOffice(BranchOffice createBranch)
{
Branches.Add(createBranch);
}
public static Company CreateCompany(UpdateCompany updateCompany)
public class Validator : AbstractValidator<Company>
{
throw new NotImplementedException();
public Validator()
{
RuleFor(x => x.Nip)
.NotEmpty()
.WithMessage("error.company.nip.empty");
RuleFor(x => x.Name)
.NotEmpty()
.WithMessage("error.company.name.empty");
}
}
}
}

View File

@ -1,8 +1,24 @@
namespace InternshipSystem.Core
using System.Collections.Generic;
namespace InternshipSystem.Core.Entity
{
public class Course
{
public long Id { get; set; }
public string Name { get; set; }
public string NameEng { get; set; }
public static Course CreateCourse(string name, string nameEng) =>
new Course
{
Name = name,
NameEng = nameEng,
};
public void UpdateCourse(string name, string nameEng)
{
Name = name;
NameEng = nameEng;
}
}
}

View File

@ -6,9 +6,19 @@ namespace InternshipSystem.Core
{
public long Id { get; set; }
public string Description { get; set; }
public byte[] Scan { get; set; }
public DocumentScan Scan { get; set; }
public DocumentType Type { get; set; }
public DocumentState State { get; set; }
public string RejectionReason { get; set; }
public string ChangeStateComment { get; set; }
}
public class DocumentScan
{
public long DocumentId { get; set; }
public Document Document { get; set; }
public long Size { get; set; }
public string Filename { get; set; }
public string Mime { get; set; }
public byte[] File { get; set; }
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -14,39 +15,130 @@ namespace InternshipSystem.Core
public DateTime ReportingStart { get; set; }
public Course Course { get; set; }
public List<Internship> Internships { get; set; }
public InternshipType AllowedInternshipTypes { get; set; }
public List<EditionSubject> AvailableSubjects { get; set; }
public List<InternshipType> AvailableInternshipTypes { get; set; }
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
public List<ReportFieldEdition> ReportSchema { get; set; }
public bool IsOpen => EditionFinish < DateTime.Today;
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course,
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
{
var newEdition = CreateEdition(start, end, reportingStart, course);
newEdition.AvailableSubjects =
subjectsIds
.Select(s => new EditionSubject
{
Edition = newEdition,
InternshipSubjectId = s,
})
.ToList();
newEdition.AvailableInternshipTypes =
internshipTypesIds
.Select(i => new EditionInternshipType
{
Edition = newEdition,
InternshipTypeId = i,
})
.ToList();
newEdition.ReportSchema =
reportFieldIds
.Select(i => new ReportFieldEdition
{
Edition = newEdition,
ReportFieldId = i,
})
.ToList();
return newEdition;
}
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course)
{
return new Edition
{
EditionStart = start,
EditionFinish = end,
ReportingStart = reportingStart
ReportingStart = reportingStart,
Course = course,
AvailableSubjects = new List<EditionSubject>(),
AvailableInternshipTypes = new List<EditionInternshipType>(),
ReportSchema = new List<ReportFieldEdition>()
};
}
public bool IsInternshipTypeAllowed(InternshipType registrationQueryType)
public void UpdateEdition(DateTime? start, DateTime? end, DateTime? reportingStart, Course course,
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
{
return AvailableInternshipTypes.Contains(registrationQueryType);
EditionStart = start ?? EditionStart;
EditionFinish = end ?? EditionFinish;
ReportingStart = reportingStart ?? ReportingStart;
Course = course;
if (subjectsIds != null)
{
AvailableSubjects =
subjectsIds
.Select(s => new EditionSubject
{
InternshipSubjectId = s,
})
.ToList();
}
if (internshipTypesIds != null)
{
AvailableInternshipTypes =
internshipTypesIds
.Select(i => new EditionInternshipType
{
InternshipTypeId = i,
})
.ToList();
}
if (reportFieldIds != null)
{
ReportSchema =
reportFieldIds
.Select(i => new ReportFieldEdition
{
ReportFieldId = i,
})
.ToList();
}
}
public void RegisterInternship(Student student)
{
var internship = Internship.CreateStudentsInternship(student);
if (Internships.Any(i => i.Student.Id == student.Id))
{
throw new ArgumentException("error.registration.already_registered");
}
var internship = Internship.CreateStudentsInternship(student);
Internships.Add(internship);
}
public void ValidateInternshipRegistration(InternshipRegistration internshipRegistration)
public bool IsDateDuringEdition(DateTime start, DateTime end)
{
throw new NotImplementedException();
return start >= EditionStart && end <= EditionFinish;
}
public bool IsTypeAvailable(InternshipType internshipType)
{
return AvailableInternshipTypes.Any(e => e.InternshipType == internshipType);
}
public bool AreSubjectsAvailable(IEnumerable<long> internshipSubjects)
{
return internshipSubjects.All(s => AvailableSubjects.Any(su => su.InternshipSubjectId == s));
}
public bool IsValidDates => EditionStart <= EditionFinish;
}
}

View File

@ -0,0 +1,15 @@
using System.Collections.Generic;
using System.Linq;
using FluentValidation.Results;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core
{
static internal class Extensions
{
public static IEnumerable<ErrorDescription> ToErrorDescription(this ValidationResult result)
{
return result.Errors.Select(failure => new ErrorDescription { Key = failure.ErrorCode, Parameters = failure.FormattedMessagePlaceholderValues });
}
}
}

View File

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using InternshipSystem.Core.Commands;
using InternshipSystem.Core.UglyOrmArtifacts;
using FluentValidation;
using InternshipSystem.Core.ValueObject;
namespace InternshipSystem.Core
namespace InternshipSystem.Core.Entity.Internship
{
public class Internship
{
@ -13,30 +12,10 @@ namespace InternshipSystem.Core
public Student Student { get; set; }
public InternshipRegistration InternshipRegistration { get; set; }
public Report Report { get; set; }
public List<Document> Approvals { get; set; }
public List<Document> Documentation { get; set; }
public Edition Edition { get; set; }
public float? Grade { get; set; }
public void UpdateDocument(Document document)
{
var oldDocument = Documentation.First(d => d.Id == document.Id);
oldDocument.Description = document.Description ?? oldDocument.Description;
oldDocument.Scan = document.Scan ?? oldDocument.Scan;
oldDocument.Type = document.Type;
oldDocument.State = DocumentState.Submitted;
}
public void AddNewDocument(Document document)
{
document.State = DocumentState.Submitted;
Documentation.Add(document);
}
public float? Grade { get; set; }
public static Internship CreateStudentsInternship(Student student)
{
@ -46,22 +25,81 @@ namespace InternshipSystem.Core
internship.InternshipRegistration = InternshipRegistration.Create();
internship.Report = Report.Create();
internship.Approvals = new List<Document>();
internship.Documentation = new List<Document>();
if (student.Semester != 6)
{
internship.AddNewDocument("", DocumentType.OutsideSemesterApproval);
}
return internship;
}
public void UpdateInternshipRegistration(UpdateRegistrationForm updateRegistration)
public void AddNewDocument(string description, DocumentType type)
{
InternshipRegistration.UpdateDates(updateRegistration.Start, updateRegistration.End);
InternshipRegistration.UpdateSubjects(updateRegistration.Subjects);
InternshipRegistration.UpdateInternshipType(updateRegistration.Type);
if (type != DocumentType.Other && Documentation.Any(d => d.Type == type))
{
return;
}
InternshipRegistration.UpdateCompany(updateRegistration.Company);
InternshipRegistration.UpdateMentor(updateRegistration.Mentor);
var document = new Document
{
Description = description,
Type = type,
State = DocumentState.Draft
};
Documentation.Add(document);
}
Edition.ValidateInternshipRegistration(InternshipRegistration);
public void RemoveDocument(DocumentType documentType)
{
if (documentType == DocumentType.Other)
{
return;
}
var doc = Documentation.FirstOrDefault(d => d.Type == documentType);
if (doc != null)
{
Documentation.Remove(doc);
}
}
public void RemoveDocument(long id)
{
var doc = Documentation.FirstOrDefault(d => d.Id == id);
if (doc != null)
{
Documentation.Remove(doc);
}
}
public IEnumerable<ErrorDescription> ValidateStatus()
{
var validator = new Validator();
var result = validator.Validate(this);
return result.ToErrorDescription();
}
private class Validator : AbstractValidator<Internship>
{
public Validator()
{
RuleFor(i => i.Report)
.Must(r => r.State == DocumentState.Accepted)
.WithMessage("error.report.not_accepted");
RuleFor(i => i.InternshipRegistration)
.Must(r => r.State == DocumentState.Accepted)
.WithMessage("error.registration.not_accepted");
RuleForEach(i => i.Documentation)
.Must(d => d.State == DocumentState.Accepted)
.WithMessage("error.documentation.not_accepted");
}
}
}
}

View File

@ -1,19 +0,0 @@
using System.Collections.Generic;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
namespace InternshipSystem.Core
{
public class InternshipProgram
{
public long Id { get; set; }
public Mentor Mentor { get; set; }
public DocumentState State { get; set; }
public List<ProgramSubject> ChosenSubjects { get; set; }
public static InternshipProgram Create()
{
return new InternshipProgram();
}
}
}

View File

@ -1,59 +1,82 @@
using System;
using System.Collections.Generic;
using InternshipSystem.Core.Commands;
using InternshipSystem.Core.Entity.Internship;
using System.Linq;
using FluentValidation;
using InternshipSystem.Core.UglyOrmArtifacts;
namespace InternshipSystem.Core
namespace InternshipSystem.Core.Entity.Internship
{
public class InternshipRegistration
{
public long Id { get; set; }
public Company Company { get; set; }
public BranchOffice BranchAddress { get; set; }
public DateTime SubmissionDate { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public Mentor Mentor { get; set; }
public List<ProgramSubject> ChosenSubjects { get; set; }
public List<ProgramSubject> Subjects { get; set; }
public InternshipType Type { get; set; }
public int DeclaredHours { get; set; }
public DocumentState State { get; set; }
public string ChangeStateComment { get; set; }
public static InternshipRegistration Create()
{
return new InternshipRegistration();
}
public void Update(DateTime start, DateTime end, InternshipType internshipType)
public (DocumentState State, IEnumerable<ErrorDescription>) ValidateStatus(Edition edition)
{
Start = start;
End = end;
Type = internshipType;
var validator = new Validator(edition);
var result = validator.Validate(this);
State = result.IsValid ? DocumentState.Submitted : DocumentState.Draft;
SubmissionDate = DocumentState.Submitted.Equals(State) ? DateTime.UtcNow.AddHours(1) : SubmissionDate;
return (State, result.ToErrorDescription());
}
public void UpdateCompany(UpdateCompany? updateRegistrationCompany)
public class Validator : AbstractValidator<InternshipRegistration>
{
throw new NotImplementedException();
}
public void UpdateDates(DateTime? updateRegistrationStart, DateTime? updateRegistrationEnd)
{
throw new NotImplementedException();
}
public void UpdateMentor(UpdateMentor updateRegistrationMentor)
{
throw new NotImplementedException();
}
public void UpdateSubjects(List<InternshipSubject> updateRegistrationSubjects)
{
throw new NotImplementedException();
}
public void UpdateInternshipType(InternshipType updateRegistrationType)
{
throw new NotImplementedException();
public Validator(Edition edition)
{
RuleFor(x => x.Company)
.SetValidator(new Company.Validator())
.NotNull();
RuleFor(x => x.BranchAddress)
.SetValidator(new BranchOffice.Validator())
.NotNull();
RuleFor(x => x.Mentor)
.SetValidator(new Mentor.Validate())
.NotNull();
RuleFor(x => x.Subjects)
.NotEmpty()
.Must(s => edition.AreSubjectsAvailable(s.Select(su => su.InternshipSubjectId)))
.WithMessage("error.subjects.not_available");
RuleFor(x => x.Type)
.NotNull()
.Must(edition.IsTypeAvailable)
.WithMessage("error.type.not_available");
RuleFor(x => x.Start)
.NotEmpty()
.WithMessage("error.start_date.empty");
RuleFor(x => x.End)
.NotEmpty()
.WithMessage("error.end_date.empty");
RuleFor(x => x.DeclaredHours)
.NotEmpty()
.WithMessage("error.declared_hours.empty");
}
}
}
public class ErrorDescription
{
public string Key { get; set; }
public Dictionary<string, object> Parameters { get; set; }
}
}

View File

@ -3,8 +3,11 @@
public class InternshipType
{
public long Id { get; set; }
public string Type { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public bool RequireDeansApproval { get; set; }
public bool RequireInsurance { get; set; }
}
}

View File

@ -6,12 +6,17 @@ namespace InternshipSystem.Core
{
public long Id { get; set; }
public DocumentState State { get; set; }
public RangeOfActivity Range { get; set; }
public Uri SiteAddress { get; set; }
public string Value { get; set; }
public static Report Create()
{
return new Report();
}
public void UpdateReport(string reportValue)
{
Value = reportValue;
State = DocumentState.Submitted;
}
}
}

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace InternshipSystem.Core.Entity
{
public class ReportField
{
public ReportField()
{
}
public ReportField(string label, string labelEng, string description, string descriptionEng, FieldType fieldType)
{
Label = label;
LabelEng = labelEng;
Description = description;
DescriptionEng = descriptionEng;
FieldType = fieldType;
}
public long Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public FieldType FieldType { get; set; }
}
public enum FieldType
{
LongText,
ShortText,
Select,
Radial,
Checkbox
}
public class ReportChoiceField : ReportField
{
public ReportChoiceField(string label, string labelEng, string description, string descriptionEng,
FieldType fieldType, string[] choices) : base(label, labelEng, description, descriptionEng, fieldType)
{
Choices = choices;
}
public string[] Choices { get; set; }
}
}

View File

@ -9,6 +9,8 @@ namespace InternshipSystem.Core
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Course { get; set; }
public int? Semester { get; set; }
public static Student CreateStudent(long id, string firstName, string lastName, string email, in int albumNumber)
{

View File

@ -0,0 +1,16 @@
using System;
using InternshipSystem.Core.Entity.Internship;
namespace InternshipSystem.Core.UglyOrmArtifacts
{
public class EditionInternshipType
{
public Edition Edition { get; set; }
public Guid EditionId { get; set; }
public InternshipType InternshipType { get; set; }
public long InternshipTypeId { get; set; }
}
}

View File

@ -4,8 +4,8 @@ namespace InternshipSystem.Core.UglyOrmArtifacts
{
public class ProgramSubject
{
public long InternshipId { get; set; }
public InternshipRegistration InternshipRegistration { get; set; }
public long InternshipRegistrationId { get; set; }
public InternshipRegistration Registration { get; set; }
public long InternshipSubjectId { get; set; }
public InternshipSubject Subject { get; set; }
}

View File

@ -0,0 +1,13 @@
using System;
using InternshipSystem.Core.Entity;
namespace InternshipSystem.Core.UglyOrmArtifacts
{
public class ReportFieldEdition
{
public Guid EditionId { get; set; }
public Edition Edition { get; set; }
public long ReportFieldId { get; set; }
public ReportField Field { get; set; }
}
}

View File

@ -1,34 +0,0 @@
using FluentValidation;
using FluentValidation.Validators;
namespace InternshipSystem.Core.Validators
{
public class InternshipRegistrationValidator : AbstractValidator<InternshipRegistration>
{
public InternshipRegistrationValidator(Edition edition)
{
RuleFor(ir => ir.Start)
.GreaterThanOrEqualTo(edition.EditionStart)
.LessThanOrEqualTo(edition.EditionFinish);
RuleFor(ir => ir.End)
.GreaterThanOrEqualTo(ir => ir.Start)
.LessThanOrEqualTo(edition.EditionFinish);
RuleFor(ir => ir.Company)
.SetValidator(new CompanyValidator());
RuleFor(ir => ir.BranchAddress)
.SetValidator(new BranchAddressValidator());
}
}
public class BranchAddressValidator : AbstractValidator<BranchOffice>
{
}
public class CompanyValidator : AbstractValidator<Company>
{
}
}

View File

@ -1,4 +1,7 @@
namespace InternshipSystem.Core
using FluentValidation;
using FluentValidation.Validators;
namespace InternshipSystem.Core
{
public class BranchAddress
{
@ -7,5 +10,27 @@
public string City { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public class Validator : AbstractValidator<BranchAddress>
{
public Validator()
{
RuleFor(x => x.Country)
.NotEmpty()
.WithMessage("error.branch.country.empty");
RuleFor(x => x.City)
.NotEmpty()
.WithMessage("error.branch.city.empty");
RuleFor(x => x.PostalCode)
.NotEmpty()
.WithMessage("error.branch.postal_code.empty");
RuleFor(x => x.Street)
.NotEmpty()
.WithMessage("error.branch.street.empty");
RuleFor(x => x.Building)
.NotEmpty()
.WithMessage("error.branch.building.empty");
}
}
}
}

View File

@ -2,9 +2,15 @@
{
public enum DocumentState
{
NotSubmitted,
// Oczekujaca
Draft,
// Oczekuje na akceptacje
Submitted,
// Zaakceptowana
Accepted,
Rejected
// Odrzucona
Rejected,
// Archiwalna
Archival
}
}

View File

@ -2,6 +2,12 @@
{
public enum DocumentType
{
IPPScan
IppScan,
OutsideTermApproval,
InternshipTypeApproval,
OutsideSemesterApproval,
NnwInsurance,
InternshipEvaluation,
Other
}
}

View File

@ -1,4 +1,6 @@
namespace InternshipSystem.Core
using FluentValidation;
namespace InternshipSystem.Core
{
public class Mentor
{
@ -6,5 +8,33 @@
public string LastName { get; set; }
public string Email { get; set; }
public string PhoneNumber { get; set; }
public void UpdateInformation(string firstName, string lastName, string email, string phoneNumber)
{
FirstName = firstName ?? FirstName;
LastName = lastName ?? LastName;
Email = email ?? Email;
PhoneNumber = phoneNumber ?? PhoneNumber;
}
public class Validate : AbstractValidator<Mentor>
{
public Validate()
{
RuleFor(x => x.FirstName)
.NotEmpty()
.WithMessage("error.mentor.first_name.empty");
RuleFor(x => x.LastName)
.NotEmpty()
.WithMessage("error.mentor.last_name.empty");
RuleFor(x => x.Email)
.NotEmpty()
.WithMessage("error.mentor.email.empty");
RuleFor(x => x.PhoneNumber)
.NotEmpty()
.WithMessage("error.mentor.phone_number.empty");
}
}
}
}

View File

@ -3,20 +3,30 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
using InternshipSystem.Core.ValueObject;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Repository
{
public class DatabaseFiller
{
private InternshipDbContext Context { get; }
public DatabaseFiller(InternshipDbContext context)
{
Context = context;
}
public InternshipDbContext Context { get; }
public async Task FillAll()
{
await FillCompanies();
await FillInternshipTypes();
await FillEditions();
await FillStaticPages();
}
public async Task FillCompanies()
{
@ -24,7 +34,6 @@ namespace InternshipSystem.Repository
{
new Company
{
Id = 1,
Name = "Intel",
// SiteAddress = new Uri("https://www.intel.com/content/www/us/en/jobs/locations/poland.html"),
Nip = "9570752316",
@ -67,7 +76,6 @@ namespace InternshipSystem.Repository
},
new Company
{
Id = 2,
Name = "Asseco Poland",
// SiteAddress = new Uri("http://pl.asseco.com"),
Nip = "5842068320",
@ -108,51 +116,52 @@ namespace InternshipSystem.Repository
{
new InternshipType
{
Type = "FreeInternship",
Label = "Umowa o organizację praktyki",
LabelEng = "Internship agreement",
Description = "Praktyka bezpłatna",
DescriptionEng = "Free internship",
RequireInsurance = true
},
new InternshipType
{
Type = "GraduateInternship",
Description = "Praktyka absolwencka",
DescriptionEng = "Graduate internship",
Label = "Umowa o praktykę absolwencką",
LabelEng = "Graduate internship agreement",
},
new InternshipType
{
Type = "FreeApprenticeship",
Description = "Praktyka bezpłatna",
DescriptionEng = "Free apprenticeship",
Label = "Umowa o staż bezpłatny",
LabelEng = "Free apprenticeship agreement",
RequireInsurance = true
},
new InternshipType
{
Type = "PaidApprenticeship",
Description = "np. przemysłowy",
DescriptionEng = "Paid apprenticeship",
Label = "Umowa o staż płatny",
LabelEng = "Paid apprenticeship agreement",
Description = "np. staż przemysłowy",
DescriptionEng = "e.g. industrial apprenticeship",
},
new InternshipType
{
Type = "ForeignInternship",
Description = "np. IAESTE, ERASMUS",
DescriptionEng = "Foreign internship",
Label = "Praktyka Zagraniczna",
LabelEng = "Foreign Internship",
Description = "IAESTE, ERASMUS",
DescriptionEng = "IAESTE, ERASMUS",
},
new InternshipType
{
Type = "UOP",
Description = "umowa o pracę",
DescriptionEng = "contract of employment",
Label = "Umowa o pracę",
LabelEng = "Contract of employment",
},
new InternshipType
{
Type = "UD",
Description = "umowa o dzieło",
DescriptionEng = "contract work",
Label = "Umowa o dzieło (w tym B2B)",
LabelEng = "Contract work (including B2B)",
},
new InternshipType
{
Type = "UZ",
Description = "umowa zlecenie",
DescriptionEng = "contract of mandate"
Label = "Umowa zlecenia (w tym B2B)",
LabelEng = "Contract of mandate (including B2B)",
RequireDeansApproval = true
},
};
await Context.InternshipTypes.AddRangeAsync(internshipTypes);
@ -166,9 +175,9 @@ namespace InternshipSystem.Repository
new Edition
{
Id = Guid.Parse("138da8a3-855c-4b17-9bd2-5f357679efa9"),
EditionStart = new DateTime(2000, 5, 10),
EditionFinish = new DateTime(2000, 11, 10),
ReportingStart = new DateTime(2000, 9, 30),
EditionStart = new DateTime(2020, 5, 10),
EditionFinish = new DateTime(2020, 12, 10),
ReportingStart = new DateTime(2020, 9, 30),
AvailableSubjects = new List<EditionSubject>
{
new EditionSubject
@ -199,16 +208,88 @@ namespace InternshipSystem.Repository
Course = new Course
{
Name = "Informatyka",
NameEng = "Informatics",
},
AvailableInternshipTypes = new List<InternshipType>
AvailableInternshipTypes = new List<EditionInternshipType>
{
Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
Context.InternshipTypes.First(t => t.Type.Equals("UD")),
Context.InternshipTypes.First(t => t.Type.Equals("FreeInternship")),
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę"))
},
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)"))
},
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło (w tym B2B)"))
},
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o organizację praktyki"))
}
},
Internships = new List<Internship>(),
}
},
new Edition
{
Id = Guid.Parse("bd0da085-8e51-400d-9630-bdab3f9f6cc8"),
EditionStart = new DateTime(2019, 5, 10),
EditionFinish = new DateTime(2019, 12, 10),
ReportingStart = new DateTime(2019, 9, 30),
AvailableSubjects = new List<EditionSubject>
{
new EditionSubject
{
Subject = new InternshipSubject
{
Description = "Modelowanie baz danych",
DescriptionEng = "Database modeling",
}
},
new EditionSubject
{
Subject = new InternshipSubject
{
Description = "Oprogramowywanie kart graficznych",
DescriptionEng = "Graphics card software",
}
},
new EditionSubject
{
Subject = new InternshipSubject
{
Description = "Projektowanie UI",
DescriptionEng = "UI design",
}
}
},
Course = new Course
{
Name = "Inżynieria Biomedyczna",
NameEng = "Biomedical Engineering",
},
AvailableInternshipTypes = new List<EditionInternshipType>
{
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę"))
},
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)"))
},
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło (w tym B2B)"))
},
new EditionInternshipType
{
InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o organizację praktyki"))
}
},
Internships = new List<Internship>(),
}
};
var edition = editions.First();
@ -217,6 +298,14 @@ namespace InternshipSystem.Repository
{
new Internship
{
Documentation = new List<Document>
{
new Document
{
Description = "doc",
Type = DocumentType.IppScan
}
},
Student = new Student
{
FirstName = "Jan",
@ -227,7 +316,8 @@ namespace InternshipSystem.Repository
InternshipRegistration = new InternshipRegistration
{
Company = Context.Companies.First(c => c.Name.Equals("Intel")),
Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")),
SubmissionDate = new DateTime(2000, 6, 2),
Start = new DateTime(2000, 7, 1),
End = new DateTime(2000, 8, 30),
State = DocumentState.Submitted,
@ -244,7 +334,7 @@ namespace InternshipSystem.Repository
Email = "howos@intel.com",
PhoneNumber = "605-555-555",
},
ChosenSubjects = new List<ProgramSubject>
Subjects = new List<ProgramSubject>
{
new ProgramSubject
{
@ -260,6 +350,7 @@ namespace InternshipSystem.Repository
}
}
},
Report = Report.Create()
},
new Internship
{
@ -273,7 +364,8 @@ namespace InternshipSystem.Repository
InternshipRegistration = new InternshipRegistration
{
Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")),
Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenia (w tym B2B)")),
SubmissionDate = new DateTime(2000, 6, 1),
Start = new DateTime(2000, 7, 1),
End = new DateTime(2000, 8, 30),
State = DocumentState.Submitted,
@ -290,7 +382,7 @@ namespace InternshipSystem.Repository
Email = "hepol@asseco.pl",
PhoneNumber = "555-525-545",
},
ChosenSubjects = new List<ProgramSubject>
Subjects = new List<ProgramSubject>
{
new ProgramSubject
{

View File

@ -1,5 +1,8 @@
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -12,10 +15,14 @@ namespace InternshipSystem.Repository
public DbSet<StaticPage> StaticPages { get; set; }
public DbSet<InternshipType> InternshipTypes { get; set; }
public DbSet<Student> Students { get; set; }
public DbSet<Course> Courses { get; set; }
public DbSet<Internship> Internships { get; set; }
public DbSet<ReportField> ReportFields { get; set; }
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
: base(options)
{
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) =>
@ -27,24 +34,51 @@ namespace InternshipSystem.Repository
modelBuilder.Entity<BranchOffice>()
.OwnsOne(bo => bo.Address);
modelBuilder.Entity<InternshipRegistration>()
.OwnsOne(ip => ip.Mentor);
modelBuilder.Entity<InternshipRegistration>()
.OwnsOne(ir => ir.Mentor);
modelBuilder.Entity<DocumentScan>(builder =>
{
builder
.HasKey(scan => scan.DocumentId);
builder
.HasOne(s => s.Document)
.WithOne(d => d.Scan);
});
modelBuilder.Entity<ProgramSubject>(builder =>
{
builder
.HasKey(subject => new {subject.InternshipId, subject.InternshipSubjectId });
.HasKey(subject => new { InternshipProgramId = subject.InternshipRegistrationId, subject.InternshipSubjectId });
builder
.HasOne(k => k.InternshipRegistration)
.WithMany(model => model.ChosenSubjects)
.HasForeignKey(subject => subject.InternshipId);
.HasOne(k => k.Registration)
.WithMany(model => model.Subjects)
.HasForeignKey(subject => subject.InternshipRegistrationId);
builder
.HasOne(k => k.Subject)
.WithMany()
.HasForeignKey(subject => subject.InternshipSubjectId);
});
modelBuilder.Entity<EditionInternshipType>(builder =>
{
builder
.HasKey(type => new { type.EditionId, type.InternshipTypeId});
builder
.HasOne(k => k.Edition)
.WithMany(model => model.AvailableInternshipTypes)
.HasForeignKey(p => p.EditionId);
builder
.HasOne(k => k.InternshipType)
.WithMany()
.HasForeignKey(type => type.InternshipTypeId);
});
modelBuilder.Entity<EditionSubject>(builder =>
{
@ -61,6 +95,37 @@ namespace InternshipSystem.Repository
.WithMany()
.HasForeignKey(subject => subject.InternshipSubjectId);
});
modelBuilder.Entity<ReportFieldEdition>(builder =>
{
builder
.HasKey(e => new {e.EditionId, e.ReportFieldId});
builder
.HasOne(e => e.Edition)
.WithMany(edition => edition.ReportSchema)
.HasForeignKey(r => r.EditionId);
builder
.HasOne(e => e.Field)
.WithMany()
.HasForeignKey(r => r.ReportFieldId);
});
modelBuilder.Entity<ReportField>()
.HasDiscriminator<string>("field_discrimnator")
.HasValue<ReportField>("single")
.HasValue<ReportChoiceField>("choice");
modelBuilder.Entity<ReportChoiceField>()
.Property(r => r.Choices)
.HasConversion(
a => string.Join('#', a),
s => s.Split('#', StringSplitOptions.RemoveEmptyEntries));
modelBuilder.Entity<Report>()
.Property(r => r.Value)
.HasColumnType("jsonb");
}
}
}

View File

@ -9,10 +9,10 @@ namespace InternshipSystem.Repository {
public InternshipDbContext CreateDbContext(string[] args)
{
var optionsBulider = new DbContextOptionsBuilder<InternshipDbContext>();
optionsBulider.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu");
var optionsBuilder = new DbContextOptionsBuilder<InternshipDbContext>();
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu");
return new InternshipDbContext(optionsBulider.Options);
return new InternshipDbContext(optionsBuilder.Options);
}
}
}

View File

@ -0,0 +1,794 @@
// <auto-generated />
using System;
using InternshipSystem.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
[Migration("20210110210810_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_branch_office");
b.HasIndex("CompanyId")
.HasName("ix_branch_office_company_id");
b.ToTable("branch_office");
});
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<string>("Nip")
.HasColumnName("nip")
.HasColumnType("text");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_companies");
b.ToTable("companies");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnName("type")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_document");
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.Property<long>("DocumentId")
.HasColumnName("document_id")
.HasColumnType("bigint");
b.Property<byte[]>("File")
.HasColumnName("file")
.HasColumnType("bytea");
b.Property<string>("Filename")
.HasColumnName("filename")
.HasColumnType("text");
b.Property<string>("Mime")
.HasColumnName("mime")
.HasColumnType("text");
b.Property<long>("Size")
.HasColumnName("size")
.HasColumnType("bigint");
b.HasKey("DocumentId")
.HasName("pk_document_scan");
b.ToTable("document_scan");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("uuid");
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
b.Property<DateTime>("EditionFinish")
.HasColumnName("edition_finish")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("EditionStart")
.HasColumnName("edition_start")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("ReportingStart")
.HasColumnName("reporting_start")
.HasColumnType("timestamp without time zone");
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("CourseId")
.HasName("ix_editions_course_id");
b.ToTable("editions");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<string>("NameEng")
.HasColumnName("name_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_courses");
b.ToTable("courses");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<float?>("Grade")
.HasColumnName("grade")
.HasColumnType("real");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internships");
b.HasIndex("EditionId")
.HasName("ix_internships_edition_id");
b.HasIndex("InternshipRegistrationId")
.HasName("ix_internships_internship_registration_id");
b.HasIndex("ReportId")
.HasName("ix_internships_report_id");
b.HasIndex("StudentId")
.HasName("ix_internships_student_id");
b.ToTable("internships");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("BranchAddressId")
.HasColumnName("branch_address_id")
.HasColumnType("bigint");
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<int>("DeclaredHours")
.HasColumnName("declared_hours")
.HasColumnType("integer");
b.Property<DateTime>("End")
.HasColumnName("end")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("Start")
.HasColumnName("start")
.HasColumnType("timestamp without time zone");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<DateTime>("SubmissionDate")
.HasColumnName("submission_date")
.HasColumnType("timestamp without time zone");
b.Property<long?>("TypeId")
.HasColumnName("type_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internship_registration");
b.HasIndex("BranchAddressId")
.HasName("ix_internship_registration_branch_address_id");
b.HasIndex("CompanyId")
.HasName("ix_internship_registration_company_id");
b.HasIndex("TypeId")
.HasName("ix_internship_registration_type_id");
b.ToTable("internship_registration");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_subject");
b.ToTable("internship_subject");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_report_fields");
b.ToTable("report_fields");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_report");
b.ToTable("report");
});
modelBuilder.Entity("InternshipSystem.Core.StaticPage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("AccessName")
.HasColumnName("access_name")
.HasColumnType("text");
b.Property<string>("Content")
.HasColumnName("content")
.HasColumnType("text");
b.Property<string>("ContentEng")
.HasColumnName("content_eng")
.HasColumnType("text");
b.Property<string>("Title")
.HasColumnName("title")
.HasColumnType("text");
b.Property<string>("TitleEng")
.HasColumnName("title_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_static_pages");
b.ToTable("static_pages");
});
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("AlbumNumber")
.HasColumnName("album_number")
.HasColumnType("integer");
b.Property<string>("Course")
.HasColumnName("course")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b.Property<int?>("Semester")
.HasColumnName("semester")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_students");
b.ToTable("students");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipTypeId")
.HasColumnName("internship_type_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipTypeId")
.HasName("pk_edition_internship_type");
b.HasIndex("InternshipTypeId")
.HasName("ix_edition_internship_type_internship_type_id");
b.ToTable("edition_internship_type");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipSubjectId")
.HasName("pk_edition_subject");
b.HasIndex("InternshipSubjectId")
.HasName("ix_edition_subject_internship_subject_id");
b.ToTable("edition_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.Property<long>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
.HasName("pk_program_subject");
b.HasIndex("InternshipSubjectId")
.HasName("ix_program_subject_internship_subject_id");
b.ToTable("program_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("ReportFieldId")
.HasColumnName("report_field_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "ReportFieldId")
.HasName("pk_report_field_edition");
b.HasIndex("ReportFieldId")
.HasName("ix_report_field_edition_report_field_id");
b.ToTable("report_field_edition");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
{
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
b.Property<string>("Choices")
.HasColumnName("choices")
.HasColumnType("text");
b.HasDiscriminator().HasValue("choice");
});
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.HasOne("InternshipSystem.Core.Company", null)
.WithMany("Branches")
.HasForeignKey("CompanyId")
.HasConstraintName("fk_branch_office_companies_company_id");
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
{
b1.Property<long>("BranchOfficeId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Building")
.HasColumnName("building")
.HasColumnType("text");
b1.Property<string>("City")
.HasColumnName("city")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnName("country")
.HasColumnType("text");
b1.Property<string>("PostalCode")
.HasColumnName("postal_code")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnName("street")
.HasColumnType("text");
b1.HasKey("BranchOfficeId")
.HasName("pk_branch_office");
b1.ToTable("branch_office");
b1.WithOwner()
.HasForeignKey("BranchOfficeId")
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internships_internship_id");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.HasOne("InternshipSystem.Core.Document", "Document")
.WithOne("Scan")
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
.HasConstraintName("fk_document_scan_document_document_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
.WithMany()
.HasForeignKey("CourseId")
.HasConstraintName("fk_editions_courses_course_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("Internships")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internships_editions_edition_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
.WithMany()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_internships_internship_registration_internship_registration");
b.HasOne("InternshipSystem.Core.Report", "Report")
.WithMany()
.HasForeignKey("ReportId")
.HasConstraintName("fk_internships_report_report_id");
b.HasOne("InternshipSystem.Core.Student", "Student")
.WithMany()
.HasForeignKey("StudentId")
.HasConstraintName("fk_internships_students_student_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
{
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
.WithMany()
.HasForeignKey("BranchAddressId")
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
b.HasOne("InternshipSystem.Core.Company", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.HasConstraintName("fk_internship_registration_companies_company_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.HasConstraintName("fk_internship_registration_internship_types_type_id");
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
{
b1.Property<long>("InternshipRegistrationId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b1.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b1.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b1.Property<string>("PhoneNumber")
.HasColumnName("phone_number")
.HasColumnType("text");
b1.HasKey("InternshipRegistrationId")
.HasName("pk_internship_registration");
b1.ToTable("internship_registration");
b1.WithOwner()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableInternshipTypes")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_internship_type_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "InternshipType")
.WithMany()
.HasForeignKey("InternshipTypeId")
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableSubjects")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_subject_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
.WithMany()
.HasForeignKey("InternshipSubjectId")
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "Registration")
.WithMany("Subjects")
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_program_subject_internship_registration_internship_registrat")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
.WithMany()
.HasForeignKey("InternshipSubjectId")
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("ReportSchema")
.HasForeignKey("EditionId")
.HasConstraintName("fk_report_field_edition_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
.WithMany()
.HasForeignKey("ReportFieldId")
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,537 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "companies",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
nip = table.Column<string>(nullable: true),
name = table.Column<string>(nullable: true),
provider = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_companies", x => x.id);
});
migrationBuilder.CreateTable(
name: "courses",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column<string>(nullable: true),
name_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_courses", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_subject",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_subject", x => x.id);
});
migrationBuilder.CreateTable(
name: "internship_types",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
label = table.Column<string>(nullable: true),
label_eng = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true),
require_deans_approval = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_types", x => x.id);
});
migrationBuilder.CreateTable(
name: "report",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
state = table.Column<int>(nullable: false),
value = table.Column<string>(type: "jsonb", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_report", x => x.id);
});
migrationBuilder.CreateTable(
name: "report_fields",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
label = table.Column<string>(nullable: true),
label_eng = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true),
field_type = table.Column<int>(nullable: false),
field_discrimnator = table.Column<string>(nullable: false),
choices = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_report_fields", x => x.id);
});
migrationBuilder.CreateTable(
name: "static_pages",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
access_name = table.Column<string>(nullable: true),
title = table.Column<string>(nullable: true),
title_eng = table.Column<string>(nullable: true),
content = table.Column<string>(nullable: true),
content_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_static_pages", x => x.id);
});
migrationBuilder.CreateTable(
name: "students",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
album_number = table.Column<int>(nullable: false),
first_name = table.Column<string>(nullable: true),
last_name = table.Column<string>(nullable: true),
email = table.Column<string>(nullable: true),
course = table.Column<string>(nullable: true),
semester = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_students", x => x.id);
});
migrationBuilder.CreateTable(
name: "branch_office",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
street = table.Column<string>(nullable: true),
building = table.Column<string>(nullable: true),
city = table.Column<string>(nullable: true),
postal_code = table.Column<string>(nullable: true),
country = table.Column<string>(nullable: true),
provider = table.Column<long>(nullable: false),
company_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_branch_office", x => x.id);
table.ForeignKey(
name: "fk_branch_office_companies_company_id",
column: x => x.company_id,
principalTable: "companies",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "editions",
columns: table => new
{
id = table.Column<Guid>(nullable: false),
edition_start = table.Column<DateTime>(nullable: false),
edition_finish = table.Column<DateTime>(nullable: false),
reporting_start = table.Column<DateTime>(nullable: false),
course_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_editions", x => x.id);
table.ForeignKey(
name: "fk_editions_courses_course_id",
column: x => x.course_id,
principalTable: "courses",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "internship_registration",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
company_id = table.Column<long>(nullable: true),
branch_address_id = table.Column<long>(nullable: true),
submission_date = table.Column<DateTime>(nullable: false),
start = table.Column<DateTime>(nullable: false),
end = table.Column<DateTime>(nullable: false),
first_name = table.Column<string>(nullable: true),
last_name = table.Column<string>(nullable: true),
email = table.Column<string>(nullable: true),
phone_number = table.Column<string>(nullable: true),
type_id = table.Column<long>(nullable: true),
declared_hours = table.Column<int>(nullable: false),
state = table.Column<int>(nullable: false),
change_state_comment = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internship_registration", x => x.id);
table.ForeignKey(
name: "fk_internship_registration_branch_office_branch_address_id",
column: x => x.branch_address_id,
principalTable: "branch_office",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_registration_companies_company_id",
column: x => x.company_id,
principalTable: "companies",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internship_registration_internship_types_type_id",
column: x => x.type_id,
principalTable: "internship_types",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "edition_internship_type",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
internship_type_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_edition_internship_type", x => new { x.edition_id, x.internship_type_id });
table.ForeignKey(
name: "fk_edition_internship_type_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_edition_internship_type_internship_types_internship_type_id",
column: x => x.internship_type_id,
principalTable: "internship_types",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "edition_subject",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_edition_subject", x => new { x.edition_id, x.internship_subject_id });
table.ForeignKey(
name: "fk_edition_subject_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_edition_subject_internship_subject_internship_subject_id",
column: x => x.internship_subject_id,
principalTable: "internship_subject",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "report_field_edition",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
report_field_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_report_field_edition", x => new { x.edition_id, x.report_field_id });
table.ForeignKey(
name: "fk_report_field_edition_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_report_field_edition_report_fields_report_field_id",
column: x => x.report_field_id,
principalTable: "report_fields",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "internships",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
student_id = table.Column<long>(nullable: true),
internship_registration_id = table.Column<long>(nullable: true),
report_id = table.Column<long>(nullable: true),
edition_id = table.Column<Guid>(nullable: true),
grade = table.Column<float>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_internships", x => x.id);
table.ForeignKey(
name: "fk_internships_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internships_internship_registration_internship_registration",
column: x => x.internship_registration_id,
principalTable: "internship_registration",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internships_report_report_id",
column: x => x.report_id,
principalTable: "report",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_internships_students_student_id",
column: x => x.student_id,
principalTable: "students",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "program_subject",
columns: table => new
{
internship_registration_id = table.Column<long>(nullable: false),
internship_subject_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_program_subject", x => new { x.internship_registration_id, x.internship_subject_id });
table.ForeignKey(
name: "fk_program_subject_internship_registration_internship_registrat",
column: x => x.internship_registration_id,
principalTable: "internship_registration",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_program_subject_internship_subject_internship_subject_id",
column: x => x.internship_subject_id,
principalTable: "internship_subject",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "document",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
description = table.Column<string>(nullable: true),
type = table.Column<int>(nullable: false),
state = table.Column<int>(nullable: false),
change_state_comment = table.Column<string>(nullable: true),
internship_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_document", x => x.id);
table.ForeignKey(
name: "fk_document_internships_internship_id",
column: x => x.internship_id,
principalTable: "internships",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "document_scan",
columns: table => new
{
document_id = table.Column<long>(nullable: false),
size = table.Column<long>(nullable: false),
filename = table.Column<string>(nullable: true),
mime = table.Column<string>(nullable: true),
file = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_document_scan", x => x.document_id);
table.ForeignKey(
name: "fk_document_scan_document_document_id",
column: x => x.document_id,
principalTable: "document",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_branch_office_company_id",
table: "branch_office",
column: "company_id");
migrationBuilder.CreateIndex(
name: "ix_document_internship_id",
table: "document",
column: "internship_id");
migrationBuilder.CreateIndex(
name: "ix_edition_internship_type_internship_type_id",
table: "edition_internship_type",
column: "internship_type_id");
migrationBuilder.CreateIndex(
name: "ix_edition_subject_internship_subject_id",
table: "edition_subject",
column: "internship_subject_id");
migrationBuilder.CreateIndex(
name: "ix_editions_course_id",
table: "editions",
column: "course_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_branch_address_id",
table: "internship_registration",
column: "branch_address_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_company_id",
table: "internship_registration",
column: "company_id");
migrationBuilder.CreateIndex(
name: "ix_internship_registration_type_id",
table: "internship_registration",
column: "type_id");
migrationBuilder.CreateIndex(
name: "ix_internships_edition_id",
table: "internships",
column: "edition_id");
migrationBuilder.CreateIndex(
name: "ix_internships_internship_registration_id",
table: "internships",
column: "internship_registration_id");
migrationBuilder.CreateIndex(
name: "ix_internships_report_id",
table: "internships",
column: "report_id");
migrationBuilder.CreateIndex(
name: "ix_internships_student_id",
table: "internships",
column: "student_id");
migrationBuilder.CreateIndex(
name: "ix_program_subject_internship_subject_id",
table: "program_subject",
column: "internship_subject_id");
migrationBuilder.CreateIndex(
name: "ix_report_field_edition_report_field_id",
table: "report_field_edition",
column: "report_field_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "document_scan");
migrationBuilder.DropTable(
name: "edition_internship_type");
migrationBuilder.DropTable(
name: "edition_subject");
migrationBuilder.DropTable(
name: "program_subject");
migrationBuilder.DropTable(
name: "report_field_edition");
migrationBuilder.DropTable(
name: "static_pages");
migrationBuilder.DropTable(
name: "document");
migrationBuilder.DropTable(
name: "internship_subject");
migrationBuilder.DropTable(
name: "report_fields");
migrationBuilder.DropTable(
name: "internships");
migrationBuilder.DropTable(
name: "editions");
migrationBuilder.DropTable(
name: "internship_registration");
migrationBuilder.DropTable(
name: "report");
migrationBuilder.DropTable(
name: "students");
migrationBuilder.DropTable(
name: "courses");
migrationBuilder.DropTable(
name: "branch_office");
migrationBuilder.DropTable(
name: "internship_types");
migrationBuilder.DropTable(
name: "companies");
}
}
}

View File

@ -0,0 +1,798 @@
// <auto-generated />
using System;
using InternshipSystem.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
[Migration("20210111195519_Insurance")]
partial class Insurance
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_branch_office");
b.HasIndex("CompanyId")
.HasName("ix_branch_office_company_id");
b.ToTable("branch_office");
});
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<string>("Nip")
.HasColumnName("nip")
.HasColumnType("text");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_companies");
b.ToTable("companies");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnName("type")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_document");
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.Property<long>("DocumentId")
.HasColumnName("document_id")
.HasColumnType("bigint");
b.Property<byte[]>("File")
.HasColumnName("file")
.HasColumnType("bytea");
b.Property<string>("Filename")
.HasColumnName("filename")
.HasColumnType("text");
b.Property<string>("Mime")
.HasColumnName("mime")
.HasColumnType("text");
b.Property<long>("Size")
.HasColumnName("size")
.HasColumnType("bigint");
b.HasKey("DocumentId")
.HasName("pk_document_scan");
b.ToTable("document_scan");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("uuid");
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
b.Property<DateTime>("EditionFinish")
.HasColumnName("edition_finish")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("EditionStart")
.HasColumnName("edition_start")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("ReportingStart")
.HasColumnName("reporting_start")
.HasColumnType("timestamp without time zone");
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("CourseId")
.HasName("ix_editions_course_id");
b.ToTable("editions");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<string>("NameEng")
.HasColumnName("name_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_courses");
b.ToTable("courses");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<float?>("Grade")
.HasColumnName("grade")
.HasColumnType("real");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internships");
b.HasIndex("EditionId")
.HasName("ix_internships_edition_id");
b.HasIndex("InternshipRegistrationId")
.HasName("ix_internships_internship_registration_id");
b.HasIndex("ReportId")
.HasName("ix_internships_report_id");
b.HasIndex("StudentId")
.HasName("ix_internships_student_id");
b.ToTable("internships");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("BranchAddressId")
.HasColumnName("branch_address_id")
.HasColumnType("bigint");
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<int>("DeclaredHours")
.HasColumnName("declared_hours")
.HasColumnType("integer");
b.Property<DateTime>("End")
.HasColumnName("end")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("Start")
.HasColumnName("start")
.HasColumnType("timestamp without time zone");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<DateTime>("SubmissionDate")
.HasColumnName("submission_date")
.HasColumnType("timestamp without time zone");
b.Property<long?>("TypeId")
.HasColumnName("type_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internship_registration");
b.HasIndex("BranchAddressId")
.HasName("ix_internship_registration_branch_address_id");
b.HasIndex("CompanyId")
.HasName("ix_internship_registration_company_id");
b.HasIndex("TypeId")
.HasName("ix_internship_registration_type_id");
b.ToTable("internship_registration");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_subject");
b.ToTable("internship_subject");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.Property<bool>("RequireInsurance")
.HasColumnName("require_insurance")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_report_fields");
b.ToTable("report_fields");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_report");
b.ToTable("report");
});
modelBuilder.Entity("InternshipSystem.Core.StaticPage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("AccessName")
.HasColumnName("access_name")
.HasColumnType("text");
b.Property<string>("Content")
.HasColumnName("content")
.HasColumnType("text");
b.Property<string>("ContentEng")
.HasColumnName("content_eng")
.HasColumnType("text");
b.Property<string>("Title")
.HasColumnName("title")
.HasColumnType("text");
b.Property<string>("TitleEng")
.HasColumnName("title_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_static_pages");
b.ToTable("static_pages");
});
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("AlbumNumber")
.HasColumnName("album_number")
.HasColumnType("integer");
b.Property<string>("Course")
.HasColumnName("course")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b.Property<int?>("Semester")
.HasColumnName("semester")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_students");
b.ToTable("students");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipTypeId")
.HasColumnName("internship_type_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipTypeId")
.HasName("pk_edition_internship_type");
b.HasIndex("InternshipTypeId")
.HasName("ix_edition_internship_type_internship_type_id");
b.ToTable("edition_internship_type");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipSubjectId")
.HasName("pk_edition_subject");
b.HasIndex("InternshipSubjectId")
.HasName("ix_edition_subject_internship_subject_id");
b.ToTable("edition_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.Property<long>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
.HasName("pk_program_subject");
b.HasIndex("InternshipSubjectId")
.HasName("ix_program_subject_internship_subject_id");
b.ToTable("program_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("ReportFieldId")
.HasColumnName("report_field_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "ReportFieldId")
.HasName("pk_report_field_edition");
b.HasIndex("ReportFieldId")
.HasName("ix_report_field_edition_report_field_id");
b.ToTable("report_field_edition");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
{
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
b.Property<string>("Choices")
.HasColumnName("choices")
.HasColumnType("text");
b.HasDiscriminator().HasValue("choice");
});
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.HasOne("InternshipSystem.Core.Company", null)
.WithMany("Branches")
.HasForeignKey("CompanyId")
.HasConstraintName("fk_branch_office_companies_company_id");
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
{
b1.Property<long>("BranchOfficeId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Building")
.HasColumnName("building")
.HasColumnType("text");
b1.Property<string>("City")
.HasColumnName("city")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnName("country")
.HasColumnType("text");
b1.Property<string>("PostalCode")
.HasColumnName("postal_code")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnName("street")
.HasColumnType("text");
b1.HasKey("BranchOfficeId")
.HasName("pk_branch_office");
b1.ToTable("branch_office");
b1.WithOwner()
.HasForeignKey("BranchOfficeId")
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internships_internship_id");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.HasOne("InternshipSystem.Core.Document", "Document")
.WithOne("Scan")
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
.HasConstraintName("fk_document_scan_document_document_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
.WithMany()
.HasForeignKey("CourseId")
.HasConstraintName("fk_editions_courses_course_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("Internships")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internships_editions_edition_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
.WithMany()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_internships_internship_registration_internship_registration");
b.HasOne("InternshipSystem.Core.Report", "Report")
.WithMany()
.HasForeignKey("ReportId")
.HasConstraintName("fk_internships_report_report_id");
b.HasOne("InternshipSystem.Core.Student", "Student")
.WithMany()
.HasForeignKey("StudentId")
.HasConstraintName("fk_internships_students_student_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
{
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
.WithMany()
.HasForeignKey("BranchAddressId")
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
b.HasOne("InternshipSystem.Core.Company", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.HasConstraintName("fk_internship_registration_companies_company_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.HasConstraintName("fk_internship_registration_internship_types_type_id");
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
{
b1.Property<long>("InternshipRegistrationId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b1.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b1.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b1.Property<string>("PhoneNumber")
.HasColumnName("phone_number")
.HasColumnType("text");
b1.HasKey("InternshipRegistrationId")
.HasName("pk_internship_registration");
b1.ToTable("internship_registration");
b1.WithOwner()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableInternshipTypes")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_internship_type_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "InternshipType")
.WithMany()
.HasForeignKey("InternshipTypeId")
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableSubjects")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_subject_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
.WithMany()
.HasForeignKey("InternshipSubjectId")
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "Registration")
.WithMany("Subjects")
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_program_subject_internship_registration_internship_registrat")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
.WithMany()
.HasForeignKey("InternshipSubjectId")
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("ReportSchema")
.HasForeignKey("EditionId")
.HasConstraintName("fk_report_field_edition_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
.WithMany()
.HasForeignKey("ReportFieldId")
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace InternshipSystem.Repository.Migrations
{
public partial class Insurance : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "require_insurance",
table: "internship_types",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "require_insurance",
table: "internship_types");
}
}
}

View File

@ -0,0 +1,796 @@
// <auto-generated />
using System;
using InternshipSystem.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
partial class InternshipDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_branch_office");
b.HasIndex("CompanyId")
.HasName("ix_branch_office_company_id");
b.ToTable("branch_office");
});
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<string>("Nip")
.HasColumnName("nip")
.HasColumnType("text");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_companies");
b.ToTable("companies");
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<long?>("InternshipId")
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnName("type")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_document");
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.Property<long>("DocumentId")
.HasColumnName("document_id")
.HasColumnType("bigint");
b.Property<byte[]>("File")
.HasColumnName("file")
.HasColumnType("bytea");
b.Property<string>("Filename")
.HasColumnName("filename")
.HasColumnType("text");
b.Property<string>("Mime")
.HasColumnName("mime")
.HasColumnType("text");
b.Property<long>("Size")
.HasColumnName("size")
.HasColumnType("bigint");
b.HasKey("DocumentId")
.HasName("pk_document_scan");
b.ToTable("document_scan");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("uuid");
b.Property<long?>("CourseId")
.HasColumnName("course_id")
.HasColumnType("bigint");
b.Property<DateTime>("EditionFinish")
.HasColumnName("edition_finish")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("EditionStart")
.HasColumnName("edition_start")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("ReportingStart")
.HasColumnName("reporting_start")
.HasColumnType("timestamp without time zone");
b.HasKey("Id")
.HasName("pk_editions");
b.HasIndex("CourseId")
.HasName("ix_editions_course_id");
b.ToTable("editions");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Course", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name")
.HasColumnName("name")
.HasColumnType("text");
b.Property<string>("NameEng")
.HasColumnName("name_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_courses");
b.ToTable("courses");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid?>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<float?>("Grade")
.HasColumnName("grade")
.HasColumnType("real");
b.Property<long?>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long?>("ReportId")
.HasColumnName("report_id")
.HasColumnType("bigint");
b.Property<long?>("StudentId")
.HasColumnName("student_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internships");
b.HasIndex("EditionId")
.HasName("ix_internships_edition_id");
b.HasIndex("InternshipRegistrationId")
.HasName("ix_internships_internship_registration_id");
b.HasIndex("ReportId")
.HasName("ix_internships_report_id");
b.HasIndex("StudentId")
.HasName("ix_internships_student_id");
b.ToTable("internships");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<long?>("BranchAddressId")
.HasColumnName("branch_address_id")
.HasColumnType("bigint");
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<long?>("CompanyId")
.HasColumnName("company_id")
.HasColumnType("bigint");
b.Property<int>("DeclaredHours")
.HasColumnName("declared_hours")
.HasColumnType("integer");
b.Property<DateTime>("End")
.HasColumnName("end")
.HasColumnType("timestamp without time zone");
b.Property<DateTime>("Start")
.HasColumnName("start")
.HasColumnType("timestamp without time zone");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<DateTime>("SubmissionDate")
.HasColumnName("submission_date")
.HasColumnType("timestamp without time zone");
b.Property<long?>("TypeId")
.HasColumnName("type_id")
.HasColumnType("bigint");
b.HasKey("Id")
.HasName("pk_internship_registration");
b.HasIndex("BranchAddressId")
.HasName("ix_internship_registration_branch_address_id");
b.HasIndex("CompanyId")
.HasName("ix_internship_registration_company_id");
b.HasIndex("TypeId")
.HasName("ix_internship_registration_type_id");
b.ToTable("internship_registration");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_subject");
b.ToTable("internship_subject");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.Property<bool>("RequireInsurance")
.HasColumnName("require_insurance")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
b.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_report_fields");
b.ToTable("report_fields");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_report");
b.ToTable("report");
});
modelBuilder.Entity("InternshipSystem.Core.StaticPage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("AccessName")
.HasColumnName("access_name")
.HasColumnType("text");
b.Property<string>("Content")
.HasColumnName("content")
.HasColumnType("text");
b.Property<string>("ContentEng")
.HasColumnName("content_eng")
.HasColumnType("text");
b.Property<string>("Title")
.HasColumnName("title")
.HasColumnType("text");
b.Property<string>("TitleEng")
.HasColumnName("title_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_static_pages");
b.ToTable("static_pages");
});
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("AlbumNumber")
.HasColumnName("album_number")
.HasColumnType("integer");
b.Property<string>("Course")
.HasColumnName("course")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b.Property<int?>("Semester")
.HasColumnName("semester")
.HasColumnType("integer");
b.HasKey("Id")
.HasName("pk_students");
b.ToTable("students");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipTypeId")
.HasColumnName("internship_type_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipTypeId")
.HasName("pk_edition_internship_type");
b.HasIndex("InternshipTypeId")
.HasName("ix_edition_internship_type_internship_type_id");
b.ToTable("edition_internship_type");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipSubjectId")
.HasName("pk_edition_subject");
b.HasIndex("InternshipSubjectId")
.HasName("ix_edition_subject_internship_subject_id");
b.ToTable("edition_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.Property<long>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("InternshipRegistrationId", "InternshipSubjectId")
.HasName("pk_program_subject");
b.HasIndex("InternshipSubjectId")
.HasName("ix_program_subject_internship_subject_id");
b.ToTable("program_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("ReportFieldId")
.HasColumnName("report_field_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "ReportFieldId")
.HasName("pk_report_field_edition");
b.HasIndex("ReportFieldId")
.HasName("ix_report_field_edition_report_field_id");
b.ToTable("report_field_edition");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
{
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
b.Property<string>("Choices")
.HasColumnName("choices")
.HasColumnType("text");
b.HasDiscriminator().HasValue("choice");
});
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.HasOne("InternshipSystem.Core.Company", null)
.WithMany("Branches")
.HasForeignKey("CompanyId")
.HasConstraintName("fk_branch_office_companies_company_id");
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
{
b1.Property<long>("BranchOfficeId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Building")
.HasColumnName("building")
.HasColumnType("text");
b1.Property<string>("City")
.HasColumnName("city")
.HasColumnType("text");
b1.Property<string>("Country")
.HasColumnName("country")
.HasColumnType("text");
b1.Property<string>("PostalCode")
.HasColumnName("postal_code")
.HasColumnType("text");
b1.Property<string>("Street")
.HasColumnName("street")
.HasColumnType("text");
b1.HasKey("BranchOfficeId")
.HasName("pk_branch_office");
b1.ToTable("branch_office");
b1.WithOwner()
.HasForeignKey("BranchOfficeId")
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internships_internship_id");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.HasOne("InternshipSystem.Core.Document", "Document")
.WithOne("Scan")
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
.HasConstraintName("fk_document_scan_document_document_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Course", "Course")
.WithMany()
.HasForeignKey("CourseId")
.HasConstraintName("fk_editions_courses_course_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.Internship", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("Internships")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internships_editions_edition_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "InternshipRegistration")
.WithMany()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_internships_internship_registration_internship_registration");
b.HasOne("InternshipSystem.Core.Report", "Report")
.WithMany()
.HasForeignKey("ReportId")
.HasConstraintName("fk_internships_report_report_id");
b.HasOne("InternshipSystem.Core.Student", "Student")
.WithMany()
.HasForeignKey("StudentId")
.HasConstraintName("fk_internships_students_student_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipRegistration", b =>
{
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
.WithMany()
.HasForeignKey("BranchAddressId")
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
b.HasOne("InternshipSystem.Core.Company", "Company")
.WithMany()
.HasForeignKey("CompanyId")
.HasConstraintName("fk_internship_registration_companies_company_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.HasConstraintName("fk_internship_registration_internship_types_type_id");
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
{
b1.Property<long>("InternshipRegistrationId")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b1.Property<string>("Email")
.HasColumnName("email")
.HasColumnType("text");
b1.Property<string>("FirstName")
.HasColumnName("first_name")
.HasColumnType("text");
b1.Property<string>("LastName")
.HasColumnName("last_name")
.HasColumnType("text");
b1.Property<string>("PhoneNumber")
.HasColumnName("phone_number")
.HasColumnType("text");
b1.HasKey("InternshipRegistrationId")
.HasName("pk_internship_registration");
b1.ToTable("internship_registration");
b1.WithOwner()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableInternshipTypes")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_internship_type_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "InternshipType")
.WithMany()
.HasForeignKey("InternshipTypeId")
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableSubjects")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_subject_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
.WithMany()
.HasForeignKey("InternshipSubjectId")
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipRegistration", "Registration")
.WithMany("Subjects")
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_program_subject_internship_registration_internship_registrat")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
.WithMany()
.HasForeignKey("InternshipSubjectId")
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("ReportSchema")
.HasForeignKey("EditionId")
.HasConstraintName("fk_report_field_edition_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
.WithMany()
.HasForeignKey("ReportFieldId")
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,8 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading;
using InternshipSystem.Api.Commands;
using InternshipSystem.Api.Controllers;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.UseCases;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Machine.Specifications;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace InternshipSystem.Api.Test
{
@ -56,4 +64,105 @@ namespace InternshipSystem.Api.Test
private static JsonSerializerOptions options;
private static CasUserProfile result;
}
class When_doint_whatever
{
private Establish context = () =>
{
var db = new InternshipDbContext(new DbContextOptionsBuilder<InternshipDbContext>()
.UseLoggerFactory(LoggerFactory.Create(b => b.AddConsole()))
.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu")
.Options);
var company = Company.CreateCompany("a", "b");
var internship = db.Editions.First();
var list = new List<UpdateRegistrationForm> {null}.Select(form => form.Company).ToList();
db.Companies.Add(company);
db.SaveChanges();
};
private It should_whatev = () => true.ShouldBeTrue();
}
class When_writing_tests_only_for_debug_because_i_gave_up_on_code_quality
{
private Establish context = () =>
{
var db = new InternshipDbContext(new DbContextOptionsBuilder<InternshipDbContext>()
.UseLoggerFactory(LoggerFactory.Create(b => b.AddConsole()))
.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=szwoniu")
.Options);
var ed = db.Editions
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(t => t.InternshipType)
.Include(e => e.AvailableSubjects)
.ThenInclude(t => t.Subject)
.First();
var user = new User
{
PersonNumber = 1
};
var ir = db.Entry(ed)
.Collection(e => e.Internships)
.Query()
.Include(i => i.InternshipRegistration)
.ThenInclude(r => r.BranchAddress)
.Include(i => i.InternshipRegistration)
.ThenInclude(r => r.Company)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Company.Branches)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Type)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Subjects)
.Where(i => i.Student.Id == user.PersonNumber)
.First();
var useCase = new UpdateInternshipRegistrationUseCase(db, ir, ed, user);
var update = new UpdateRegistrationForm
{
Subjects = new List<long>
{
1,
2,
3
},
Type = 1
};
var task = useCase.UpdateInternshipRegistration(update, CancellationToken.None);
task.Wait();
var result = task.Result;
db.SaveChanges();
ir = db.Entry(ed)
.Collection(e => e.Internships)
.Query()
.Include(i => i.InternshipRegistration)
.ThenInclude(r => r.BranchAddress)
.Include(i => i.InternshipRegistration)
.ThenInclude(r => r.Company)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Company.Branches)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Type)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Subjects)
.Where(i => i.Student.Id == user.PersonNumber)
.First();
};
private It should_nop = () => true.ShouldBeTrue();
}
}

View File

@ -1,4 +1,4 @@
using System;
using InternshipSystem.Core.Entity.Internship;
using Machine.Specifications;
// ReSharper disable InconsistentNaming